• PHP Video Tutorials

PHP - Function array_walk_recursive()



Syntax

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.

Parameters

Sr.No Parameter & Description
1

array(Required)

It specifies an array.

2

funcname(Required)

The name of the user-made function.

3

paramter(Optional)

It specifies a parameter to the user-made function.

Example

Try out following example −

<?php
   function call_back_function($value,$key) {
      echo "The key $key has the value $value \n";
   }
   
   $input1 = array("a"=>"green", "b"=>"brown", "c"=>"blue" );
   $input2 = array($input1, "d"=>"yellow", "e"=>"black");
   
   array_walk_recursive($input2,"call_back_function");
?> 

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
php_function_reference.htm
Advertisements