array_walk_recursive
array_walk_recursive
Apply a user function recursively to every member of an array
true **array_walk_recursive** $array callable $callback mixed $arg
Applies the user-defined function to each
element of the . This function will recurse
into deeper arrays.
callback``array
arrayThe input array.
callback
Typically, takes on two parameters.
The parameter's value being the first, and
the key/index second.
callback``array
Opmerking: > If needs to be working with the actual values of the array, specify the first parameter of as a . Then, any changes made to those elements will be made in the original array itself.
callback``callbackreference
arg
If the optional parameter is supplied,
it will be passed as the third parameter to the
.
arg``callback
return.true.always
Voorbeeld: example
<?php
$sweet = array('a' => 'apple', 'b' => 'banana');
$fruits = array('sweet' => $sweet, 'sour' => 'lemon');
function test_print($item, $key)
{
echo "$key holds $item\n";
}
array_walk_recursive($fruits, 'test_print');
?>
a holds apple
b holds banana
sour holds lemon
You may notice that the key '' is never displayed. Any key that holds an
will not be passed to the function.
`sweet``array`
array_walk