3v4l.org

run code in 300+ PHP versions simultaneously
<ul> <?php $values = array(); $values[] = array('example'=>'example1','date'=>'2016-12-25'); $values[] = array('example'=>'example2','date'=>'2016-12-26'); $values[] = array('example'=>'example3','date'=>'2016-12-28'); $values[] = array('example'=>'example4','date'=>'2016-12-30'); $previous = null; foreach($values as $example){ echo "<li>".$example['example']." - ".$example['date']; if ($previous !== null) { $diff = strtotime($example['date'])-strtotime($previous); echo " - ".($diff/(60*60*24)); } $previous = $example['date']; echo "</li>\n"; } ?> </ul>
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
<ul> <li>example1 - 2016-12-25</li> <li>example2 - 2016-12-26 - 1</li> <li>example3 - 2016-12-28 - 2</li> <li>example4 - 2016-12-30 - 2</li> </ul>

preferences:
94.09 ms | 408 KiB | 5 Q