我有这个数组
$array = array(
"one" => "bar",
"two" => "21",
"three" => "22",
"four" => "25",
"five" => array(
"xxxxxxxxxxxxxxxxxx" => array(
"ar1" => "food",
"ar2" => "dr",
"ar3" => "ch",
"ar4" => "ju"
),
"yyyyyyyyyyyyyyyyyyyy" => array(
"ar1" => "food",
"ar2" => "dr",
"ar3" => "ch",
"ar4" => "ju"
)),
"six" => "et",
"seven" => "op",
"eight" => "hjs",
"nine" => array(
"1" => array(
"ar5" => "food",
"ar87" => "dr",
"ar21" => "ch",
"ar443" => "ju"
),
"2" => array(
"73" => "food",
"82" => "dr",
"90" => "ch",
"2123" => "ju"
)),
"ten" => "bar",
"eleven" => "bar",
"twelve" => "bar"
);
并且正在像这样找到给定级别的所有数组键
foreach ($array['five'] as $keyed=> $user) {
foreach ($user as $key => $value) {
echo "Key: $key; Value: $value Keyed: $keyed<br />\n";
}
}
但是,我想获取所有找到的数组键以供使用,array_key_exists
所以我需要将找到的键转换为数组。我正在尝试通过拥有这个数组
function the_keys($val){
foreach ($val['five'] as $keyed=> $user) {
foreach ($user as $key => $value) {
$keyed = array();
}
}
}
但即使这样也不会像我想的那样将找到的键转换为数组。我需要做什么才能将找到的键转换为数组?