3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ["01/06/18", "02/06/18", "03/06/18", "11/06/18","12/06/18", "13/06/18", "14/06/18", "15/06/18","16/06/18", "20/06/18"]; $i =-1; $prev =0; $format = "d/m/y"; Foreach($arr as $val){ $dt = date_create_from_format ($format , $val); $unix = date_timestamp_get($dt); If($unix -$prev > 86400){ $i++; } $res[$i][] = $unix; $prev = $unix; } Foreach($res as $period){ If(count($period) >1){ $periods[] = date($format, min($period)) . " - " . date($format, max($period)); }Else{ $periods[] = date($format, min($period)); } } Var_dump($periods);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> string(19) "01/06/18 - 03/06/18" [1]=> string(19) "11/06/18 - 16/06/18" [2]=> string(8) "20/06/18" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
30.89 ms | 405 KiB | 5 Q