Jump to content

Array trouble within a while loop


josephman1988

Recommended Posts

Hi guys,

 

Need some help with arrays!

 

The following code puts ALL dates into an array, or should I say should.

Because this:

 

do {

$start = $row_getCalendarDates['page_date'];
$end = $row_getCalendarDates['page_date02'];

$init_date = strtotime($start);
$dst_date = strtotime($end);

$offset = $dst_date-$init_date;

$dates = floor($offset/60/60/24) + 1;

$booked=0;
while ($booked < $dates) {
$newDateFinal[] = date("Y-m-d", mktime(12,0,0,date("m", strtotime($start)),
(date("d", strtotime($start)) + $booked), date("Y", strtotime($start))));

$booked++;
}

print_r($newDateFinal);

} while ($row_getCalendarDates = mysql_fetch_assoc($getCalendarDates)); 

 

Infact prints something like so when i have multiple results:

Array ( [0] => 2010-12-01 [1] => 2010-12-02 [2] => 2010-12-03 ) Array ( [0] => 2010-12-01 [1] => 2010-12-02 [2] => 2010-12-03 [3] => 2010-11-01 [4] => 2010-11-02 [5] => 2010-11-03 [6] => 2010-11-04 [7] => 2010-11-05 [8] => 2010-11-06 [9] => 2010-11-07 [10] => 2010-11-08 )

 

These are 2 results coming from the database, so what it is doing is putting both into arrays, but I 'NEED' them iin a single array, how on earth do I go about doing this?

Note however, how the first array has the first set of results but the second has them all ... this is affecting my code and so, need to somehow reference and get rid of the first array.

 

Hope someone can help!

Regards,

Joe.

Link to comment
Share on other sites

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.