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'];
http://www.bkjia.com/PHPjc/313623.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/313623.htmlTechArticlePHP版: 複製程式碼如下: $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');...