array_map() with NULL

<?php

$a = range('a', 'd');
$b = range(13, 16);
$c = ['Orange', 'Blue', 'Red', 'White'];

$e = array_map(null, $a, $b, $c);
print_r($e);

array_map() calls a closure on a selection of arrays. It is lesser known that the closure may be null. In that case, what can be the meaning of mapping arrays with … nothing?.

It turns out that PHP applies a zip operation on the array: it takes the first element of each array, pack it in another array, and set it in the result. Then, does this again.

In the end, it is the opposite to array_column().

See Also

PHP Features

Last updated: 18 August 2026