3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $update_flag = 0; $row_avail = array( 'field_windows_value' => '2014-09-18T00:00:00', 'field_windows_value2' => '2015-09-30T00:00:00' ); if ( $row_avail['field_windows_value'] != $row_avail['field_windows_value2'] ) { if ( strtotime($row_avail['field_windows_value']) < time() && time() <= strtotime($row_avail['field_windows_value2']) ) { $update_flag = 1; } } else { if ( strtotime($row_avail['field_windows_value']) < time() && $row_avail['field_windows_value'] != NULL ) { $update_flag = 1; } } print $update_flag."\n"; $update_flag = 0; $last_start = 0; if ( $row_avail['field_windows_value'] != $row_avail['field_windows_value2'] ) { if ( strtotime($row_avail['field_windows_value2']) < time() ) { if ( $last_start != 0 && $last_start > time() ) { $update_flag = 1; break; } elseif ( $last_start == 0 ) { $update_flag = 1; break; } } } else { if ( strtotime($row_avail['field_windows_value2']) > time() && $row_avail['field_windows_value'] != NULL ) { $update_flag = 1; break; } } $last_start = $row_avail['field_windows_value']; print $update_flag."\n"; print $last_start."\n"; //$last_start = 0; $avail_result = array ( array ( 'field_availability_block_start_date' => '2014-09-18 00:00:00', 'field_availability_block_end_date' => '2015-09-30 00:00:00', ), array ( 'field_availability_block_start_date' => '2015-09-30 00:00:00', 'field_availability_block_end_date' => '2016-09-30 00:00:00', ), ); $loop_itr = 0; foreach ( $avail_result AS $row_avail ) { $loop_itr++; print "loop_itr = ".$loop_itr."\n"; if ( $row_avail['field_availability_block_start_date'] != $row_avail['field_availability_block_end_date'] ) { print "start != end\n"; if ( strtotime($row_avail['field_availability_block_end_date']) < time() ) { print "end < time\n"; if ( $last_start != 0 && $last_start > time() ) { $update_flag = 1; break; } elseif ( $last_start == 0 ) { $update_flag = 1; break; } } } else { if ( strtotime($row_avail['field_availability_block_end_date']) > time() && $row_avail['field_availability_block_start_date'] != NULL ) { print "end > time and start != NULL\n"; $update_flag = 1; break; } } $last_start = $row_avail['field_availability_block_start_date']; } print strtotime($row_avail['field_availability_block_end_date'])."\n"; print $update_flag."\n"; print $last_start."\n";
based on va1gm
Output for 5.4.0 - 5.6.28
1 0 2014-09-18T00:00:00 loop_itr = 1 start != end loop_itr = 2 start != end 1475186400 0 2015-09-30 00:00:00