array mapphp make new array php code example
Example 1: using array map php
array_map ( callable $callback , array $array1 [, array $... ] ) : array
Example 2: php array map
$func = function cube($n) {
return ($n * $n * $n);
}
$a = [1, 2, 3, 4, 5];
$b = array_map( $func, $a );
// Outputs: Array (
// [0] => 2
// [1] => 4
// [2] => 6
// [3] => 8
// [4] => 10
// )