faqts : Computers : Programming : Languages : PHP : Common Problems : Arrays

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 6 people (67%) answered Yes
Recently 4 of 6 people (67%) answered Yes

Entry

Have two arrays A + B, want new C. How to merge A1->C1,B1->C2,A2->C3,B2->C4 and so on?

Apr 24th, 2003 01:39
Johnny Hennum,


This should do it:

for ($i = 0; $i < $A_or_B_length; $i++) {
   C[$i*2] = A[$i];
   C[$i*2+1] = B[$i];
   }