I've been trying to write a PHP function which searches the id
index valeus in array, and once found, returns the path which lead to it's discovery.
Take the following array:
Array
(
[0] => Array
(
[id] => 1
[data] => Array
(
[0] => Array
(
[id] => 8
)
[1] => Array
(
[id] => 9
)
[2] => Array
(
[id] => 10
[data] => Array
(
[0] => Array
(
[id] => 15
[data] => Array
(
[0] => Array
(
[id] => 22
)
)
)
[1] => Array
(
[id] => 21
)
)
)
)
)
)
If looking for [id] => 21
it would return array(1,10)
. However, in numerous attempts I have failed. The set path should be set to the index id
. However, I cannot figure it out. Any words of guidance are much appreciated.