Make associative array from two arrays

From: Date: Wed, 01 Aug 2001 14:15:58 +0000
Subject: Make associative array from two arrays
Groups: php.general 
Request: Send a blank email to php-general+get-60644@lists.php.net to get a copy of this message
Hello! I have two arrays: $keys = array("a", "b", "c", "d"); $vals = array(1, 2, 3, 4); I would like to get an associative array holding this: $aarray = array("a" =>1, "b"=>2, "c"=>3, "d"=>4); I know I can do it with a "while" loop...but I wonder if there is any builtin PHP function that can do that. Or a better method other than sort of this: $aarray = array(); for ($i=0;$i<count($keys);$i++) { $aarray[$keys[$i]] = $vals[$i]; } thanks!

« previous php.general (#60644) next »