array_map

It applies the callback to the elements of the given arrays

Example

<?php
function squr($arg){
return($arg * $arg );
}
echo “<pre>”;
$array1 = array(1,7,5,1,9,8,4);
$array2 = array_map(“squr”, $array1);
print_r($array2);
?>

Output

Array
(
[0] => 1
[1] => 49
[2] => 25
[3] => 1
[4] => 81
[5] => 64
[6] => 16
)

Share