Posted in PHP onSeptember 16, 2013
PHP版:
$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和JavaScrip分别获取关联数组的键值示例代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@