3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '2018-10-03' => 5, '2018-10-06' => 5, '2018-10-09' => 5, '2018-10-03' => 4, ]; $rotate = []; foreach ($array as $date => $value) { $rotate[$value][] = $date; } $group = []; foreach ($rotate as $value => $dates) { $group[] = [ 'start' => min($dates), 'end' => max($dates), 'value' => $value ]; } var_dump($rotate); var_dump($group);

preferences:
24.03 ms | 406 KiB | 5 Q