3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ [ 'name' => 'Event A', 'date' => '2023-03-1' ], [ 'name' => 'Event B', 'date' => '2023-03-2' ], [ 'name' => 'Event C', 'date' => '2023-03-3' ], [ 'name' => 'Event D', 'date' => '2023-03-7' ], [ 'name' => 'Event E', 'date' => '2023-03-9' ], ]; $start_d = null; $curr_d = null; $groups = []; foreach($data as $d){ $dd = DateTime::createFromFormat('!Y-m-d', $d['date']); if($start_d == null){ $start_d = $curr_d = $dd; }else{ $diff = $dd->diff($curr_d) ; if($diff->y === 0 && $diff->m === 0 && $diff->d === 1){ $curr_d = $dd; }else{ $groups[] = [$start_d->format('d'), $curr_d->format('d')]; $start_d = $curr_d = $dd; } } } $groups[] = [$start_d->format('d'), $curr_d->format('d')]; echo implode(" , ", array_map(fn($v) => implode(" - ", array_unique($v)), $groups)), " / ", $start_d->format('m'), " / ", $start_d->format('Y');
Output for git.master, git.master_jit, rfc.property-hooks
01 - 03 , 07 , 09 / 03 / 2023

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:
85.3 ms | 405 KiB | 5 Q