Populating an array
Posted: Sun Jun 13, 2010 4:26 pm
I have a foreach loop which simply echoes several variables. What I want to do now is populate an array with these variables. My code is as follows:
I would like these vars arranged in a multidimensional array with the structure as follows:
$arr = array($nation => array($var1, $var2), $nation => array($var1, $var2), $nation => array($var1, $var2));
How can I achieve this?
Thank you in advance.
Code: Select all
foreach($nations as $nation){
print($var1);
print($var2);
}
$arr = array($nation => array($var1, $var2), $nation => array($var1, $var2), $nation => array($var1, $var2));
How can I achieve this?
Thank you in advance.