3v4l.org

run code in 500+ PHP versions simultaneously
<?php $sampleData = [ ['group' => 'g1', 'branch' => 'b1', 'unit' => 'null'], ['group' => 'g1', 'branch' => 'b1', 'unit' => 'u2'], ['group' => 'g2', 'branch' => 'null', 'unit' => 'u3'], ['group' => 'g2', 'branch' => 'b6', 'unit' => 'u4'], ['group' => 'g3', 'branch' => 'b7', 'unit' => 'u5'], ]; $groups = []; foreach($sampleData as $row){ $groups[$row['group']][$row['branch']][] = $row['unit']; } var_dump($groups);
Output for rfc.property-hooks, git.master, git.master_jit
array(3) { ["g1"]=> array(1) { ["b1"]=> array(2) { [0]=> string(4) "null" [1]=> string(2) "u2" } } ["g2"]=> array(2) { ["null"]=> array(1) { [0]=> string(2) "u3" } ["b6"]=> array(1) { [0]=> string(2) "u4" } } ["g3"]=> array(1) { ["b7"]=> array(1) { [0]=> string(2) "u5" } } }

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:
95.05 ms | 1165 KiB | 4 Q