3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datesarray = array('2012-10-01', '2012-10-03', '2012-10-04', '2012-10-05', '2012-10-08', '2012-10-09'); $count = 0; $result = "Nothing found"; $diff = strtotime('2014-05-07') - strtotime('2014-05-06'); for ($i=2, $c=count($datesarray); $i<$c; ++$i) { if (strtotime($datesarray[$i-1]) - strtotime($datesarray[$i-2]) == $diff && strtotime($datesarray[$i]) - strtotime($datesarray[$i-2]) == $diff * 2) { $result = "3 Consecutive dates found"; break; } } echo "Result: $result";
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Result: 3 Consecutive dates found