function transpose($array) {
array_unshift($array, null);
return call_user_func_array('array_map', $array);
}
NULL is given as the parameter to array_unshift
, which adds a value to the start of the array. So, the first line inserts NULL as the first value of the array. The next line calls array_map with all the entries of $array as the parameters. So it's the same as calling array_map(NULL, $array[0], $array[1], $array[2], etc etc)
. In the array_map documentation there's a detail: "An interesting use of this function is to construct an array of arrays, which can be easily performed by using NULL as the name of the callback function"