Menu Riverview Church

ARRAY_WALK_RECURSIVE

Apply a user function recursively to every member of an array

SYNTAX

array_walk_recursive ( array &$array , callable $callback [, mixed $userdata = NULL ] ) : bool

PARAMETERS

array

The input array.

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 reference. Then, any changes made to those elements will be made in the original array itself.

userdata

If the optional userdata parameter is supplied, it will be passed as the third parameter to the callback.

RETURN

Returns TRUE on success or FALSE on failure.

EXAMPLES

ARRAY CALLBACK

Array
(
    [a] => Array
        (
            [0] => oranges
            [1] => limes
        )

    [b] => bananas
    [c] => apples
    [d] => lemons
)

USERDATA

Array
(
    [a] => Array
        (
            [0] => fruit: oranges
            [1] => fruit: limes
        )

    [b] => fruit: bananas
    [c] => fruit: apples
    [d] => fruit: lemons
)

PHP