3v4l.org

run code in 300+ PHP versions simultaneously
<?php const DATA = [ [1070, 1023, 'this is the first record'], [1070, 1028, 'this is the second record'], [1098, 1023, 'this is the thrid record'], [1098, 1028, 'this is the fourth record'], [2021, 1023, 'this is the fifth record'], [2021, 1028, 'this is the sixth record'], ]; function group_records(array $data, int $col) { $last = null; $current = []; foreach (DATA as $row) { if ($row[$col] !== $last && $last !== null) { yield $last => $current; $last = null; $current = []; } $last = $row[$col]; $current[] = $row; } if ($last !== null) { yield $last => $current; } } foreach (group_records(DATA, 0) as $key => $rows) { echo "$key:\n"; foreach ($rows as $row) echo " " . implode('|', $row) . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
1070: 1070|1023|this is the first record 1070|1028|this is the second record 1098: 1098|1023|this is the thrid record 1098|1028|this is the fourth record 2021: 2021|1023|this is the fifth record 2021|1028|this is the sixth record

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