Jump to content

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
https://forums.phpfreaks.com/topic/219682-array-trouble-within-a-while-loop/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.