Query: array_walk_recursive
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
ARRAY_WALK_RECURSIVE(3) 1 ARRAY_WALK_RECURSIVE(3) array_walk_recursive - Apply a user function recursively to every member of an arraySYNOPSISbool array_walk_recursive NULL (array &$array, callable $callback, [mixed $userdata])DESCRIPTIONApplies the user-defined $callback function to each element of the $array. This function will recurse into deeper arrays.PARAMETERSo $array - The input array. o $callback - Typically, $callback takes on two parameters. The $array parameter's value being the first, and the key/index second. Note If $callback needs to be working with the actual values of the array, specify the first parameter of $callback as a refer- ence. Then, any changes made to those elements will be made in the original array itself. o $userdata - If the optional $userdata parameter is supplied, it will be passed as the third parameter to the $callback.RETURN VALUESReturns TRUE on success or FALSE on failure.EXAMPLESExample #1 array_walk_recursive(3) example <?php $sweet = array('a' => 'apple', 'b' => 'banana'); $fruits = array('sweet' => $sweet, 'sour' => 'lemon'); function test_print($item, $key) { echo "$key holds $item "; } array_walk_recursive($fruits, 'test_print'); ?> The above example will output: a holds apple b holds banana sour holds lemon You may notice that the key ' sweet' is never displayed. Any key that holds an array will not be passed to the function.SEE ALSOarray_walk(3), information about the callback type. PHP Documentation Group ARRAY_WALK_RECURSIVE(3)
Related Man Pages |
---|
key(3) - php |
rsort(3) - php |
arsort(3) - php |
array_walk(3) - php |
uksort(3) - php |
Similar Topics in the Unix Linux Community |
---|
$# question |
How to declare hashes in KSH similar to Perl ? |
Unix Forms |
how to put element of an array to first position. |
How to get next string of a matching string? |