我有以下数组:
Array ( [0] => Array ( [word] => 1 [question] => php [position] => 11 ) [1] => Array ( [word] => sql [question] => 1 [position] => 22 ) )我需要查找数组中是否存在 [position] => 22 并保留数组路径以供进一步参考.谢谢.
I need to find if [position] => 22 exists in my array and retain the array path for further reference. Thank you.
推荐答案你可以试试这个代码:
$array = array ( array ( "word" => 1, "question" => php, "position" => 11 ), array ( "word" => sql, "question" => 1, "position" => 22 ) ); foreach($array as $item) { foreach($item as $key=>$value) { if($key=="position" && $value=="22") { echo "found"; } } }