PHP在多维数组中搜索Key [英] PHP search for Key in multidimensional array
本文介绍了PHP在多维数组中搜索Key的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个:
Array
(
[carx] => Array
(
[no] => 63
)
[cary] => Array
(
[no] => 64
)
)
当我有 no=63 时,如何找到钥匙 carx ?我知道如何使用 array_search()
但是这个有点棘手.就像我可以找到键名 id
而我有 63
但这有点棘手.
How can I find the key carx when i have the no=63 ? i know how to use array_search()
but this one is a bit tricky. Like i can find key name id
while I have 63
But this one is a bit tricky.
有人可以帮我吗?
推荐答案
foreach ($array as $i => $v) $array[$i] = $v['no'];
$key = array_search(63, $array);
这篇关于PHP在多维数组中搜索Key的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文