Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP array_walk_recursive() Function

PHP array_walk_recursive() Function

PHP Array ReferenceComplete PHP Array Reference Manual

Example

Apply a user-defined function to every element of an array:

"; } $a1=array("a"=>"red","b"=>"green"); $a2=array($a1,"1"=>"blue","2"=>"yellow"); array_walk_recursive($a2,"myfunction"); ?>

Run Example »


Definition and Usage

The array_walk_recursive() function applies a user-defined function to every element of an array. In the function, the array key and value are the parameters. The difference between this function and array_walk() is that it can operate on deeper arrays (an array containing another array).


Syntax

array_walk_recursive(

array,myfunction,parameter...

)

Parameters Description
array Required. Specifies the array.
myfunction Required. The name of the user-defined function.
parameter,... Optional. Specifies parameters for the user-defined function; you can set one or more parameters for the function.

Technical Details

Return Value: Returns TRUE on success, FALSE on failure.
PHP Version: 5+

PHP Array ReferenceComplete PHP Array Reference Manual