B
B
banny_name2015-10-27 00:29:50
PHP
banny_name, 2015-10-27 00:29:50

How to search a multidimensional array?

I have a multidimensional array:

array(2) {
  ["one"]=>
  array(2) {
    ["a"]=>
    string(1) "z"
    ["b"]=>
    string(1) "y"
  }
  ["two"]=>
  array(2) {
    ["z"]=>
    string(1) "a"
    ["name"]=>
    string(10) "banny_boom"
  }
}

You need to find the array indexes that lead to 'banny_boom'
You can, of course, do a recursive traversal of the array, or just go through it 2 foreach, but this is nonsense.
Please tell me how to search multidimensional arrays

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2015-10-27
@banny_name

php.net/manual/en/class.recursiveiteratoriterator.php and then one forich.
or a recursive function based on array_search.

A
Aleksey Ratnikov, 2015-10-27
@mahoho

With recursive in_array()

G
Greg Popov, 2015-10-27
@Gregpopov

google

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question