Access value in PHP array with unknown dimensions -
consider multidimensional array following structure:
[a] => array ( [b] => array ( [c] => array ( [value] => 0 [other_value] => 1 ) ) ) i want access $array[a][b][c][value], value @ $array[a][b][c][d][value].
i'm not entirely how describe i'm trying do. think alternative explanation be: want access each element in $array[a][b][c] able access each element in $array[a][b][c][d], etc., using foreach, unknown number of nested arrays.
array_walk_recursive() come in handy here.
array_walk_recursive($array, function($val, $key) { if ($key == "value") { // } });
Comments
Post a Comment