Jump to content

variable variables and or array of arrays


kevin nally

Recommended Posts

Hi folks and thanks for reading this.

 

I am trying to solve a problem with an array of arrays;

I have a function that calculates the number of combinations that can be created given an array of any length.

the function works as print_r gives me the following output. Array ( [0] => Array ( [0] => 111 ) [1] => Array ( [0] => 201 ) ) Array ( [0] => Array ( [0] => 111 [1] => 201 ) )

 

ideally i would like each iteration of the loop below to create a new array so i need to use variable variables to create a new array based on $count in the for loop.

 

 

$arrayOfBets = array(111, 201,301);
for($count=1;$count<=count($arrayOfBets);$count++)
{
$newArray = comb($arrayOfBets, $count);
// I would like to be able to create $newArraytwo $newArrayThree etc according to the $count variable. if not how do i separate the arrays in to separate arrays;
print_r($newArray);
}

grateful for any help :confused:

 

 

 

 

sorry i cut the wrong code here is what i  do have


//process the number of combinations 
$arrayOfBets = array(111, 201,301);
for($count=1;$count<=count($arrayOfBets);$count++)
{
    $newArray=array();
    while ($numberOfBets=combo($numberOfBets,$count))
    {
        $newArray[]=// lost at this stage;
    }
// I would like to be able to create $newArraytwo $newArrayThree etc according to the $count variable. if not how do i separate the arrays in to separate arrays;
print_r($newArray);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.