ฉันมีอาร์เรย์ดังนี้
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'โดยดัชนีของมัน ฉันจะทำสิ่งนั้นได้อย่างไร