Applies the callback to the elements of the given arrays
The array_map() function sends each value of an array to a user-made function, and returns an array with new values, given by the user-made function.
array_map ( callable|null $callback , array $array , array …$arrays ) : array
Callback
A callable to run for each element in each array.
null can be passed as a value to callback to perform a zip operation on multiple arrays. If only array is provided, array_map() will return the input array.
Array
An array to run through the callback function.arraysSupplementary variable list of array arguments to run through the callback function.
function cube($n)
{
return ($n * $n * $n);
}
$a = [1, 2, 3, 4, 5];
$b = array_map(‘cube’, $a);
print_r($b);
?>