3v4l.org

run code in 300+ PHP versions simultaneously
<?php $menuArray = [ 'Main Street' => [], 'Activities' => [], 'Services' => [], 'Account' => [] ]; $lookup = [ 0 => 'Main Street', 1 => 'Activities', 2 => 'Services', 3 => 'Account', 4 => 'Communication' ]; $customsort = '4,2,1,3,0'; $keys = array_flip(explode(',', $customsort)); var_export($keys); $ordered_keys = array_flip(array_replace($keys, $lookup)); var_export($ordered_keys); $filtered_keys = array_intersect_key($ordered_keys, $menuArray); var_export($filtered_keys); $final = array_replace($filtered_keys, $menuArray); var_export($final);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 4 => 0, 2 => 1, 1 => 2, 3 => 3, 0 => 4, )array ( 'Communication' => 4, 'Services' => 2, 'Activities' => 1, 'Account' => 3, 'Main Street' => 0, )array ( 'Services' => 2, 'Activities' => 1, 'Account' => 3, 'Main Street' => 0, )array ( 'Services' => array ( ), 'Activities' => array ( ), 'Account' => array ( ), 'Main Street' => array ( ), )

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