Now with php array_map function you can apply a function to all values in array on one go
here is an example
<?php function cube($n) { return($n * $n * $n); } $a = array(1, 2, 3, 4, 5); $b = array_map("cube", $a); print_r($b); ?>
Result will be like this
Array ( [0] => 1 [1] => 8 [2] => 27 [3] => 64 [4] => 125 )
Leave a comment