Web | This Site

Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# 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. 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.

## Paramters

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.

## Example

Try out following example:

    <?php
    function call_back_function($value,$key)
    {
      echo "The key $key has the value $value<br />";
    }

    $array1 = array("a"=>"green", "b"=>"brown", "c"=>"blue" );
    $array2 = array($array1, "d"=>"yellow", "e"=>"black");

    array_walk_recursive($array,"call_back_function");
    ?>

This will produce 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

Advertisement

Online Image Processing

Indian Baby Names