php - get all array keys by value -
let's have array this:
array ( [start] => array ( [item 1] => array ( [0] => item 1_1 [item 2_1] => array ( [item 2_1_1] => x ) [1] => item 3_1 ) [0] => item 2 [1] => item 3 )
)
is there php function can utilize path leads value x
in array, meaning, in case result be:
start, item 1, item 2_1, item 2_1_1, x
the method can think of plenty of nested foreach ($array $key => $value)
loops array_search()
.
it improve design create recursive 1 though, using function wise.
function recursivesearch($key, $array) { foreach ($array $k => $ar) { if (is_array('x', $ar)) { homecoming $k . ', ' . array_search('x', $ar); } else { if ($ar === 'x') { homecoming $k } else { homecoming recursivesearch($key, $ar); } } } }
just take on it, not working or that.
php arrays multidimensional-array
No comments:
Post a Comment