Problems with using multiarrays
Posted: Mon Mar 08, 2004 4:50 am
This is something I have been wrestling with for a few days.
I have several arrays with I want to join and then access each joined array seperately eg:
This outputs
1 2 3 4 5 6 7 8 9 10 11 12 13 mike tom nick cynthia manak alan louise cedric alex chris emma allison sarah martin thomas king courtier davis crisp blair singh jones smith jenkins don anelka
ie: each array is appended to the end of the previous, whilst what I want is each line to be like this
array1[0], array2[0],array2[0]
array1[1], array2[1],array2[1]
array1[2], array2[2],array2[2]
array1[3], array2[3],array2[3]
array1[4], array2[4],array2[4]
I keep trying different approaches but keep coming back to this
any help appreciated
I have several arrays with I want to join and then access each joined array seperately eg:
Code: Select all
<?php
$id = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
$firstname = array(mike, tom, nick, cynthia,manak,alan,louise,cedric,alex,chris,emma,allison,sarah);
$lastname = array(martin, thomas, king, courtier, davis, crisp, blair, singh, jones, smith, jenkins, don, anelka);
$multi = array($id, $firstname, $lastname);
foreach ($multi as $v){
foreach ($v as $v1){
echo ("$v1\n");
}
}
?>1 2 3 4 5 6 7 8 9 10 11 12 13 mike tom nick cynthia manak alan louise cedric alex chris emma allison sarah martin thomas king courtier davis crisp blair singh jones smith jenkins don anelka
ie: each array is appended to the end of the previous, whilst what I want is each line to be like this
array1[0], array2[0],array2[0]
array1[1], array2[1],array2[1]
array1[2], array2[2],array2[2]
array1[3], array2[3],array2[3]
array1[4], array2[4],array2[4]
I keep trying different approaches but keep coming back to this
any help appreciated