Easy Tutorial
❮ Func Curl_Multi_Getcontent Func Filesystem Symlink ❯

PHP array_walk() Function

Complete PHP Array Reference Manual

Example

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


Definition and Usage

The array_walk() function applies a user-defined function to each element of an array. In the function, the key and value of the array are parameters.

Note: You can change the value of an array element by specifying the first parameter of the user-defined function as a reference: &$value (see Example 2).

Tip: To manipulate deeper arrays (arrays within arrays), use the array_walk_recursive() function.


Syntax

Parameter 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, otherwise FALSE.
PHP Version: 4+
--- ---

More Examples

Example 1

With one parameter:

Example 2

Change the value of an array element (note &$value):


❮ Func Curl_Multi_Getcontent Func Filesystem Symlink ❯