IMPRESS dotted_line CONTACT dotted_line search dotted_line Kontakt dotted_line sitemap dotted_line print
76 PHP-Resource users online

Switch to another languags Deutsch aktuelle Sprache Englisch

PHP Manual


(PHP 5)

array_walk_recursiveApply a user function recursively to every member of an array


bool array_walk_recursive ( array &$input , callable $funcname [, mixed $userdata = NULL ] )

Applies the user-defined function funcname to each element of the input array. This function will recurse into deeper arrays.



The input array.


Typically, funcname takes on two parameters. The input parameter's value being the first, and the key/index second.


If funcname needs to be working with the actual values of the array, specify the first parameter of funcname as a reference. Then, any changes made to those elements will be made in the original array itself.


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

Return Values

Returns TRUE on success or FALSE on failure.


Example #1 array_walk_recursive() example

= array('a' => 'apple''b' => 'banana');
$fruits = array('sweet' => $sweet'sour' => 'lemon');

"$key holds $item\n";


The above example will output:

a holds apple
b holds banana
sour holds lemon

You may notice that the key 'sweet' is never displayed. Any key that holds an array will not be passed to the function.

See Also

  • array_walk() - Apply a user function to every member of an array
  • information about the callback type

Comments to the PHP manual
Write new comment


New Tutorial entries

Migration einer PHP 5 App auf PHP 7

Dieses PHP 7 Tutorial zeigt dir, wie du dein PHP5 Script auf PHP7 umstellst.

Berni | Category: PHP
PHP 7 Virtual Machine

Dieser Artikel zielt darauf ab, einen Überblick über die Zend Virtual Machine, wie es in PHP 7 gefunden wird.

Berni | Category: PHP
plotting masters - a professional guide - Teil II

Grafische Interpolation und Bestapproximation von numerischen Wertepaaren: Wir wollen Punkte auf einer Zeichenebene über verschiedene Verfahren miteinander verbinden.

EVAMasters | Category: PHP