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++; If($i>0){ If(count($res[$i-1]) >1){ $periods[] = date($format, min($res[$i-1])) . " - " . date($format, max($res[$i-1])); }Else{ $periods[] = date($format, min($res[$i-1])); } } } $res[$i][] = $unix; $prev = $unix; } If(count(end($res)) >1){ $periods[] = date($format, min(end($res))) . " - " . date($format, max(end($res))); }Else{ $periods[] = date($format, min(end($res))); } 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:
106.36 ms | 405 KiB | 5 Q