Javatpoint Logo
Javatpoint Logo

PHP array_walk() function

The array_walk( ) function is an inbuilt function of PHP. It is used to apply a user supplied function to every element of an array. This function was introduced in 4.0.



Parameter Description Is compulsory
array The input array. compulsory
User function The name of the userdefined function. compulsory
User data If it is supplied, it will be passed as the third parameter to the user function Optional

Return Values

The array_walk( ) function returns true on success or false on failure.

Example 1


The key a has the value youtube
The key b has the value google
The key c has the value whatsapp

Example 2


Javatpoint tutorial1 has php
Javatpoint tutorial2 has java 
Javatpoint tutorial3 has python

Example 3


cricket and sachin have been paired together.
hockey and sandeep have been paired together.

Example 4


The key a has the value aajtak.
The key b has the value zee news.
The key c has the value ndtv.

Help Others, Please Share

facebook twitter pinterest