3v4l.org

run code in 300+ PHP versions simultaneously
<?php $partylist = ['party1','party2','party3']; $position = ['position1','position2']; $members = ['name1','name2','name3','name4','name5','name6']; $out = []; foreach ($members as $member) { if (!empty($out) && !next($position)) { reset($position); if(!next($partylist)) { die('Not enough parties.'.PHP_EOL); } } $out[current($partylist)][current($position)] = $member; } print_r($out);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [party1] => Array ( [position1] => name1 [position2] => name2 ) [party2] => Array ( [position1] => name3 [position2] => name4 ) [party3] => Array ( [position1] => name5 [position2] => name6 ) )

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