3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sortLikeThis = [ '5', '3', '7', '1' ]; $unsorted = [ [ 'sort' => '7', 'name' => 'Test', ], [ 'sort' => '1', 'name' => 'Test 2', ], [ 'sort' => '3', 'name' => 'Test 3', ], [ 'sort' => '5', 'name' => 'Test 4', ], [ 'sort' => '7', 'name' => 'Test 4', ], ]; usort($unsorted, function($x, $y) use ($sortLikeThis) { return array_search($x['sort'], $sortLikeThis) - array_search($y['sort'], $sortLikeThis); }); var_dump($unsorted);
Output for git.master, git.master_jit, rfc.property-hooks
array(5) { [0]=> array(2) { ["sort"]=> string(1) "5" ["name"]=> string(6) "Test 4" } [1]=> array(2) { ["sort"]=> string(1) "3" ["name"]=> string(6) "Test 3" } [2]=> array(2) { ["sort"]=> string(1) "7" ["name"]=> string(4) "Test" } [3]=> array(2) { ["sort"]=> string(1) "7" ["name"]=> string(6) "Test 4" } [4]=> array(2) { ["sort"]=> string(1) "1" ["name"]=> string(6) "Test 2" } }

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:
20.98 ms | 402 KiB | 8 Q