3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ 'sort' => 'a', 'page' => 'b', 'goo' => 'c', //'search' => 'd', 'topic' => 'e', 'foo' => 'f', 'lng' => 'g', 'poo' => 'h', ]; $lookup = [ 'lng' => 5, 'topic' => 4, 'page' => 3, 'sort' => 2, 'search' => 1, // do not declare a key with a zero value ]; uksort( $input, function($a, $b) use($lookup) { return ($lookup[$b] ?? 0) <=> ($lookup[$a] ?? 0); } ); var_export($input);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'lng' => 'g', 'topic' => 'e', 'page' => 'b', 'sort' => 'a', 'goo' => 'c', 'foo' => 'f', 'poo' => 'h', )

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:
135.96 ms | 405 KiB | 5 Q