note 33879 added to function.array-combine

From: Date: Thu, 10 Jul 2003 00:46:23 +0000
Subject: note 33879 added to function.array-combine
Groups: php.notes 
Request: Send a blank email to php-notes+get-51814@lists.php.net to get a copy of this message
array_combine for PHP 4.0.6+ function array_combine($keys, $vals) { $retour= FALSE; $limite= count($keys); if (0!=$limite && $limite==count($vals)) { $retour= array(); foreach (array_map(NULL, $keys, $vals) as $item) { $retour[ $item[0] ]= $item[1]; } } return ($retour); } it relies on the order of elements e.g. $a = array(1 => 'green','key' => 'red','yellow'); $b = array(0 => 'avocado','apple','banana'); $c = array_combine($a, $b); $c would still be Array ( [green] => avocado [red] => apple [yellow] => banana ) ---- Manual Page -- http://www.php.net/manual/en/function.array-combine.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33879 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33879&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33879&report=yes

« previous php.notes (#51814) next »