note 106856 deleted from function.array-map by danbrown
| From: | danbrown@php.net | Date: | Tue, 03 Jan 2012 22:15:43 +0000 |
| Subject: | note 106856 deleted from function.array-map by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185343@lists.php.net to get a copy of this message | ||
Note Submitter: tom at punkave dot com
----
The documentation is very roundabout in describing what happens when you have multiple arrays and
what happens when the callback function is null.
When you have multiple arrays, the callback function receives the first values from all of the
arrays as its parameters (note that this means there are multiple parameters passed to each
invocation of the callback when there are multiple arrays).
If the callback function is null, the default behavior is equivalent to this callback:
function() { return func_get_args(); }
That is, the arguments passed to the callback function are returned as an array.
This can be used to implement array_transpose in two lines, as pointed out on Stack Overflow:
http://stackoverflow.com/questions/797251/transposing-multidimensional-arrays-in-php