Using the array_map() Function
<?php
function my_callback($var) {
echo "Value: $var<BR>";
return strtoupper($var);
}
$myarray = array("hello", "this", "is", "a", "callback!");
$newarray = array_map("my_callback", $myarray);
echo "<PRE>";
print_r($newarray);
echo "</PRE>";
?>
Related examples in the same category