Have followed this group for a while, it is my turn to try send an response.

Would this angle with a for loop not be better than a foreach angle ?
<?php
 $a = array(1,2,3,4,5);
 $b = array("a","b","c","d","e");
 $c = array();

 $arraysize = sizeof($a);
 for ($i=0;$i<$arraysize;$i++) {
  $c[$a[$i]] = $b[$i];
 }
?>

/ Lars
www.ljweb.com

----- Original Message -----
From: "Jonathan Hilgeman" <[EMAIL PROTECTED]>
To: "'Shahmat Dahlan'" <[EMAIL PROTECTED]>
Cc: "PHP-DB (E-mail)" <[EMAIL PROTECTED]>
Sent: Monday, May 21, 2001 6:10 PM
Subject: RE: [PHP-DB] Merge two arrays into associative arrays?


> try:
>
> $a=array(1,2,3,4,5);
> $b=array("a","b","c","d","e");
> $c = array();
>
> foreach($a as $a_key => $a_value)
> {
> $c[$a_value] = $b[$a_key];
> }
>
> that should give you what you want.
>
> Jonathan
>
> -----Original Message-----
> From: Shahmat Dahlan [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 21, 2001 12:23 AM
> To: PHP-DB
> Subject: [PHP-DB] Merge two arrays into associative arrays?
>
>
> Is there anywhere possible for me to merge two arrays into associative
> arrays?
>
> e.g.
> $a=array(1,2,3,4,5);
> $b=array("a","b","c","d","e")
>
> into
>
> $c=array(1 => "a", 2 => "b", etc... )
>
> Thanks in advance..



-- 
PHP Database 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