array_walk
int array_walk ( array array, string func [, mixed userdata])
Apply a user defined function to every element of an array.
The first argument passed to the function is the array value
and second argument passed is key of the array. Any other user parameter
can be passed as third,fourth and so on.
The function called must be a user defined function and it should not be
a PHP’s Native function.
example 1
<?php
$arr = array(’hai’,'how’,'are’,'you’);
array_walk($arr,’print_me’);
function print_me($a)
{
echo $a;
echo ” “;
}
//will out put “hai how are you ”
?>
example 2 : Passing users parameter
<?php
function print_me($a,$c)
{
echo $c.$a;
echo “
“;
}
$arr = array(’blue’,'red’,'white’);
$car = ‘my car is’;
array_walk($arr,’print_me’,$car);
//will out put “my car is blue”
// my car is red
// my car is white
?>
?>
