3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['id' => '111', 'value' => 'abc'], ['id' => '100', 'value' => 'abc'], ['id' => '132', 'value' => 'abc'], ['id' => '222', 'value' => 'abc'], ['id' => '112', 'value' => 'abc'], ['id' => '200', 'value' => 'abc'] ]; $idPriorities = array_flip(['112', '111', '132', '100']); $idOutlier = count($idPriorities); usort( $array, function($a, $b) use ($idPriorities, $idOutlier) { return ($idPriorities[$a['id']] ?? $idOutlier) <=> ($idPriorities[$b['id']] ?? $idOutlier); } ); var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'id' => '112', 'value' => 'abc', ), 1 => array ( 'id' => '111', 'value' => 'abc', ), 2 => array ( 'id' => '132', 'value' => 'abc', ), 3 => array ( 'id' => '100', 'value' => 'abc', ), 4 => array ( 'id' => '222', 'value' => 'abc', ), 5 => array ( 'id' => '200', 'value' => 'abc', ), )

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