variable variables and arrays
Posted: Sun Jan 24, 2010 10:48 am
hi folks
i have an array of arrays that looks like this Array ( [0] => Array ( [0] => 111 ) [1] => Array ( [0] => 201 ) [2] => Array ( [0] => 301 ) ) Array ( [0] => Array ( [0] => 111 [1] => 201 ) [1] => Array ( [0] => 111 [1] => 301 ) [2] => Array ( [0] => 201 [1] => 301 ) ) Array ( [0] => Array ( [0] => 111 [1] => 201 [2] => 301 ) ) when i use print_r($newArray)
what i am trying to achive is the following when i go through each iteration of the loop create a new loop for each iteration and then to access the values of the arrays later individual
so how do i create new arrays for each iteration and how could i extract the values of the above array;
i have heard of variable variables but not sure here is my code so far.
i have an array of arrays that looks like this Array ( [0] => Array ( [0] => 111 ) [1] => Array ( [0] => 201 ) [2] => Array ( [0] => 301 ) ) Array ( [0] => Array ( [0] => 111 [1] => 201 ) [1] => Array ( [0] => 111 [1] => 301 ) [2] => Array ( [0] => 201 [1] => 301 ) ) Array ( [0] => Array ( [0] => 111 [1] => 201 [2] => 301 ) ) when i use print_r($newArray)
what i am trying to achive is the following when i go through each iteration of the loop create a new loop for each iteration and then to access the values of the arrays later individual
so how do i create new arrays for each iteration and how could i extract the values of the above array;
i have heard of variable variables but not sure here is my code so far.
Code: Select all
$arrayOfCombos = array(111, 201,301);
for($count=1;$count<=count($arrayOfCombos);$count++)
{
$newArray=array()
while ($arrayOfCombos=combo($arrayOfCombos,$count){
$newArray[$count]=$arrayOfCombos[$count];
}
print_r($newArray);
}