3v4l.org

run code in 300+ PHP versions simultaneously
<?php $my_array_to_sort= [ "data"=> [ 0=>["name"=>"orange", "id"=>23423], 1=>["name"=>"green", "id"=>34343], 2=>["name"=>"red", "id"=>65566], ] ]; $priority = [ "red"=>1, "orange"=>2, "green"=>3, ]; usort($my_array_to_sort['data'], function ($a, $b) use ($priority) { return $priority[$a['name']] - $priority[$b['name']]; }); print_r($my_array_to_sort); usort($my_array_to_sort['data'], function ($a, $b) use ($priority) { return $priority[$b['name']] - $priority[$a['name']]; }); print_r($my_array_to_sort);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [data] => Array ( [0] => Array ( [name] => red [id] => 65566 ) [1] => Array ( [name] => orange [id] => 23423 ) [2] => Array ( [name] => green [id] => 34343 ) ) ) Array ( [data] => Array ( [0] => Array ( [name] => green [id] => 34343 ) [1] => Array ( [name] => orange [id] => 23423 ) [2] => Array ( [name] => red [id] => 65566 ) ) )

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:
29.14 ms | 408 KiB | 5 Q