Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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: 11 October 2026