How about ...

foreach ($keys as $key=>$value) $new_array[$value] = $vals[$key];


Tim
        ----------
        From:  elias [SMTP:[EMAIL PROTECTED]]
        Sent:  01 August 2001 15:16
        To:  [EMAIL PROTECTED]
        Subject:  Make associative array from two arrays

        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!

        

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to