array_map
array_map returns an array containing the results of applying the callback to the corresponding value of array (and arrays if more arrays are provided) used as arguments for the callback. The number of parameters that the callback function accepts should match the number of arrays passed to array_map. Excess input arrays are ignored. An ArgumentCountError is thrown if an insufficient number of arguments is provided.
Parameters
- 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.
- arrays
-
Supplementary variable list of array arguments to run through the callback function.
Return Values
Returns an array containing the results of applying the callback function to the corresponding value of array (and arrays if more arrays are provided) used as arguments for the callback.
The returned array will preserve the keys of the array argument if and only if exactly one array is passed. If more than one array is passed, the returned array will have sequential integer keys.
Changelog
Version | Description |
8.0.0 | If callback expects a parameter to be passed by reference, this function will now emit an E_WARNING. |