我有一个如下的数组:
function example() {
/* some stuff here that pushes items with
dynamically created key strings into an array */
return array( // now lets pretend it returns the created array
'firstStringName' => $whatEver,
'secondStringName' => $somethingElse
);
}
$arr = example();
// now I know that $arr contains $arr['firstStringName'];
我需要找出 $arr['firstStringName']
的索引值,以便我能够通过循环 array_keys($arr)
并返回该键字符串 'firstStringName'
。我该如何做到这一点?