Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$array['2']['21'] = null;
我想21从上面的数组中获取而不循环,有可能吗?我想为那些只有 1 条记录的数组执行此操作。显然,我将不得不对其他人使用循环。
21
foreach ($array['2'] as $key => $value) { echo $key; //I know this does the job wondering if there is simple function }
我查看了extract()但没有完成我的工作。
试试这个 :
$arr_keys = array_keys($array['2']); echo "<pre>"; print_r($arr_keys);
参考: http: //php.net/manual/en/function.array-keys.php