PHP和JavaScrip分别获取关联数组的键值示例代码
PHP版:
JavaScrip版:
代码如下:
$o = array('x'=>1, 'y'=>2, 'z'=>3); $arr = array(); $i = 0; foreach( $o as $arr[$i++]=>$v )/*empty*/; var_dump($arr); //$arr = array('x', 'y', 'z');
JavaScrip版:
代码如下:
var o = {x:1, y:2, z:3}; var arr = [], i = 0; for ( arr[i++] in o ) /*empty*/ ; console.log( arr ); //arr = ['x', 'y', 'z'];
相关推荐
微麦PHP 2019-06-28
bcbeer 2014-02-09
likun00 2019-04-16
PETERSHEN 2017-03-15
半粒红豆 2010-12-15
rootmiss 2009-11-17
txlCandy 2019-04-25
Pythonandme 2015-05-04
weixuejunphp 2017-10-18
phpsir 2017-04-04
付海军 2019-04-16
明天你好 2012-05-24
雷潇 2010-05-19
thickbookszone 2019-02-18
FaithX 2010-07-19
xuekai0 2010-07-19
愤怒的小狐狸 2010-07-16
USTBHacker 2010-07-16