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);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [4]=> array(1) { [0]=> string(10) "2018-10-03" } [5]=> array(2) { [0]=> string(10) "2018-10-06" [1]=> string(10) "2018-10-09" } } array(2) { [0]=> array(3) { ["start"]=> string(10) "2018-10-03" ["end"]=> string(10) "2018-10-03" ["value"]=> int(4) } [1]=> array(3) { ["start"]=> string(10) "2018-10-06" ["end"]=> string(10) "2018-10-09" ["value"]=> int(5) } }

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:
129.09 ms | 406 KiB | 5 Q