3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = array('x'=>'europe','y'=>'europe','a'=>'USA','b'=>'USA','c'=>'Canada'); $newList = array(); foreach($myArray as $key => $value){ if(array_key_exists($value, $newList)) array_push($newList[$value], $key); else $newList[$value][] = $key; } print_r($newList);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [europe] => Array ( [0] => x [1] => y ) [USA] => Array ( [0] => a [1] => b ) [Canada] => Array ( [0] => c ) )

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