Disclaimer: I am aware that I have in my code deprecated mysql functions. That is on my todo list.
I have a MySql select giving me seasons for diferent items in a house booking system.
Kind of:
Low season: 2010-01-01, 2010-03-01, 100 //meaning start,end,price
This comes in my first sql:
while($season_row=mysql_fetch_assoc($season_res)){
    $seasonsArray[$season_row['id_item']][] = array(
        $season_row['season_start'], 
        $season_row['season_end'],
        $season_row['daily_price']
    );
}
The dates are defined here (arriving to the function as YYYY-mm-dd):
function seasonPrice($from,$to,$requested_item){
    $start = round(strtotime($from)/86400)*86400; // like 2008-01-01
    $end = round(strtotime($to)/86400)*86400;     // to 2015-01-01
    $formattedStart = date('Y-m-d', $start);
    $formattedEnd   = date('Y-m-d', $end);
Now I need to loop between 2 dates, between the items of the $seasonsArray and then check the price of that item in that specific day.
I did this with:
foreach($seasonsArray as $item=>$value){            
    for( $thisDay = $start; $thisDay < $end; $thisDay = $thisDay + 86400){
        foreach($value as $innerValue){     
            $season_start = roundToSeconds($innerValue[0]);
            $season_end = roundToSeconds($innerValue[1]);
            if($thisDay >= $season_start && $thisDay <= $season_end) {  
                $foundPrice[] = round($innerValue[2]);
            }
        }
        $thisSerie[] = array($thisDay * 1000, isset($foundPrice) ? $foundPrice[0] : 0);
        // security check to avoid double assigned seasons to same day
        if(count($foundPrice) > 1){ die('There is double bookings in item: '.$item);}   
        unset($foundPrice);
    }
    $seasonPrices[] = array(
        'data'=> $thisSerie,
        'label'=> 'House ID: '.$item, 
    );  
}
But I get: Fatal error: Allowed memory size of 100663296 bytes exhausted
Any suggestion on where my code can be improved to not need so much memory? Or is there a bug and I don't see it?
 
     
     
    