array_walk():
This array function visits each element of array in the user defined function.
The array's keys and values are parameters in the function,
This function will not return value.
Also it can have 3'rd parameter as optional.
<?php
function funTable($val, $key){
print $val.'==='.$key."
";
}
$arrWalk = array(1=>2,2=>2,3=>2,4=>2,5=>2);
//$arrWalk = array(1,2,3,4,5,6,7,8,9,10);
array_walk($arrWalk,'funTable');
?>
======================
// to replace all the values needs to add parameter with &
<?php
function funTable1(&$val, $key, $override=null){
if($override)
$val = 5;
}
$arrWalk = array(1=>2,2=>2,3=>2,4=>2,5=>2);
//$arrWalk = array(1,2,3,4,5,6,7,8,9,10);
array_walk($arrWalk,'funTable1',0);
//array_walk($arrWalk,'funTable1',1);
print_r($arrWalk);
?>