PHP array_walk() Function

The array_walk() function apply a user defined function to every element of an array. The user-defined function takes array’s values and keys as parameters.

Tip: To work with deeper arrays (an array inside an array), use the array_walk_recursive() function.

Parameter Description
array Required. Specifying an array
myfunction Required. The name of the user-defined function
parameter,… Optional. Specifies a parameter to the user-defined function. You can assign one parameter to the function, or as many as you like




function myfunctiondemo($value,$key,$p)
echo "$key $p $value
array_walk($array,"myfunctiondemo","has the value");


a has the value Samuel
b has the value Cooper
c has the value Lachlan

Leave a Reply

Your email address will not be published. Required fields are marked *