Jump to content

Multi Dimension Array vs. Complex while("mysql") loop


jrm

Recommended Posts

I am trying to figure out whether having a multi-dimensional array ( 4 levels ) is "better" than to have a complex while{mysql_fetch_array} :

 

a. Speed

b. Size

c. coding the output

d. which way to code the array

 


/*  
     $Year = PRTYear();
     $Month = for loop running the 1 - 12
     $TypeID = PRTType();
*/

// Array 1  
$PRT[$Year][$Month][$TypeID] = PRTTypeCountperMonth($Year,$Month,$Type);

// Array 2
$PRT[] = array("Year" => $Year, 
                                 "Month" => $Month,
                                 "Type" => $Type,
                                 "Count" => PRTTypeCountperMonth($Year, $Month, $Type));

// Array 3
$PRT[] = array($Year => array ($Month => array($Type => PRTTypeCountperMonth($Year, $Month, $Type)));

 

or

 


while($Year)  // shortened mysql statements
{
    echo "\n" . $Year;
    while($Month)
    {
        echo "\n" . $Month;
        while($Type)
        {
            echo "\n" . $Type . " Count : " . $Count;
        }
    }
}

             

           

 

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.