• PHP Video Tutorials

PHP - Function array_walk()



Syntax

array_walk ( $array, $funcname [, $parameter] );

Definition and Usage

This function returns an array containing all the values of array1 that are present in all the arguments array2, array3.

Parameters

Sr.No Parameter & Description
1

array(Required)

It specifies an array.

2

funcname(Required)

The name of the user-made function.

3

parameter(Optional)

It 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 \n";
   }
   $input = array("a"=>"green", "b"=>"brown", "c"=>"blue", "red");
   
   array_walk($input,"call_back_function");
?> 

This will produce the 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 0 has the value red
php_function_reference.htm
Advertisements