3v4l.org

run code in 300+ PHP versions simultaneously
<?php $albums = ['1','2','3','4','5','6','7','8','9','10','11','12']; $incr = 1; $section_id = 1; $sections = []; foreach ($albums as $album) { $small = ($incr % 2 == 0 && $section_id % 2 != 0) || $incr % 3 == 0; if ($section_id % 2 == 0) { $small = !$small; } $sections[$section_id][($small ? 'small' : 'big')][] = [ 'id' => $album, ]; if ($incr % 3 == 0) { $section_id++; } $incr++; } print_r($sections);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [1] => Array ( [big] => Array ( [0] => Array ( [id] => 1 ) ) [small] => Array ( [0] => Array ( [id] => 2 ) [1] => Array ( [id] => 3 ) ) ) [2] => Array ( [small] => Array ( [0] => Array ( [id] => 4 ) [1] => Array ( [id] => 5 ) ) [big] => Array ( [0] => Array ( [id] => 6 ) ) ) [3] => Array ( [big] => Array ( [0] => Array ( [id] => 7 ) ) [small] => Array ( [0] => Array ( [id] => 8 ) [1] => Array ( [id] => 9 ) ) ) [4] => Array ( [small] => Array ( [0] => Array ( [id] => 10 ) [1] => Array ( [id] => 11 ) ) [big] => Array ( [0] => Array ( [id] => 12 ) ) ) )

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:
56.15 ms | 409 KiB | 8 Q