Reputation: 487
I'm trying to work out how many meeting slots are available between two times. I'm sure I'm missing something simple with the code below as I don't often use while loops.
$start = strtotime( 'tomorrow 9am' );
$end = strtotime( 'tomorrow 9:30am' );
$length = 900;
$meetings = array();
$i = 0;
while ( $start < $end ) {
$meetings[$i]['start'] = $start;
$meetings[$i]['end'] = $start + $length;
$start + $length;
$i++;
}
It seems to be causing an infinite loop, but I can't see why.
Upvotes: 0
Views: 168
Reputation: 790
It's because you don't increment the variable $start
.
$start + $length;
This does nothing in itself and probably misses an equal sign. It should probably be:
$start += $length;
Upvotes: 1