note 36313 added to function.array-map
| From: | brendan424242 at rn2 dot php dot net | Date: | Sat, 04 Oct 2003 18:39:37 +0000 |
| Subject: | note 36313 added to function.array-map | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57818@lists.php.net to get a copy of this message | ||
I've found the compostional feature, that's supposed to do array_map(NULL, $a1, $a2)
==> [[$a1[0], $a2[0]], [$a1[1], $a[1]].... seems buggy in certain situations on 4.2.2.
Instead, I'm using this, which always works for me:
// Argh, array_map seems to be bug-ful with the NULL callback..
// Instead make my own, a la python zip():
function zip($a, $b)
{
assert( count($a) == count($b) );
$newarr = Array();
for($i=0; $i<count($a); $i++) {
$newarr[] = array($a[$i], $b[$i]);
}
return $newarr;
}
----
Manual Page -- http://www.php.net/manual/en/function.array-map.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36313
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36313&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36313&report=yes
Search Tool -- http://master.php.net/manage/user-notes.php