PHP - Function array_walk_recursive()



array_walk_recursive( $array, $funcname [,$parameter])

Definition and Usage

The array_walk_recursive() function runs each array element in a user-made function. The array's keys and values are parameters in the function. The difference between this function and the array_walk() function is that with this function you can work with deeper arrays (an array inside an array). Returns True or False.


Parameter Description
array Required. Specifies an array.
funcname Required. The name of the user-made function.
paramter Optional. Specifies a parameter to the user-made function.


Try out following example −

   function call_back_function($value,$key)
      echo "The key $key has the value $value \n";
   $array1 = array("a"=>"green", "b"=>"brown", "c"=>"blue" );
   $array2 = array($array1, "d"=>"yellow", "e"=>"black");

This will produce the following result −

The key a has the value green
The key b has the value brown
The key c has the value blue
The key d has the value yellow
The key e has the value black