3v4l.org

run code in 300+ PHP versions simultaneously
<?php // array of characters depending on other characters $characters = array( 'a' => array('c'), 'b' => array('c', 'a'), 'd' => array('c', 'a'), 'c' => array(), 'l' => array('c'), 'f' => array('l'), 't' => array('a'), 'w' => array('c', 'a'), ); function sortCharacters($characters) { uksort ($characters, function ($a, $b) use ($characters) { if (empty($characters[$a]) && empty($characters[$b])) { // equal (no dependencies) return 0; } if (empty($characters[$a]) && !empty($characters[$b])) { // a has no dependencies so is lower return -1; } if (!empty($characters[$a]) && empty($characters[$b])) { // b has no dependencies so a is higher return 1; } if (in_array($a, $characters[$b])) { // b depends on a so a is lower return -1; } if (in_array($b, $characters[$a])) { // a depends on b so a is higher return 1; } return 0; }); return $characters; } $characters = sortCharacters($characters); print_r($characters);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [c] => Array ( ) [a] => Array ( [0] => c ) [b] => Array ( [0] => c [1] => a ) [d] => Array ( [0] => c [1] => a ) [l] => Array ( [0] => c ) [f] => Array ( [0] => l ) [t] => Array ( [0] => a ) [w] => Array ( [0] => c [1] => a ) )

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:
26.51 ms | 407 KiB | 5 Q