variable variables and arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
knally1963
Forum Newbie
Posts: 1
Joined: Sun Jan 24, 2010 10:30 am

variable variables and arrays

Post by knally1963 »

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.

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);
}
 
Post Reply