3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $sort = array( array( 'type' => 'a', 'weight' => .5 ), array( 'type' => 'd', 'weight' => .5 ), array( 'type' => 'b', 'weight' => .6 ), array( 'type' => 'c', 'weight' => .7 ), ); uasort($sort, function ( $a, $b ) { if( $a['weight'] == $b['weight'] ) { return 0; } return $a['weight'] < $b['weight'] ? 1 : -1; }); print_r($sort);
Output for 7.0.0 - 7.2.0
Array ( [3] => Array ( [type] => c [weight] => 0.7 ) [2] => Array ( [type] => b [weight] => 0.6 ) [0] => Array ( [type] => a [weight] => 0.5 ) [1] => Array ( [type] => d [weight] => 0.5 ) )
Output for 5.3.21 - 5.6.28
Array ( [3] => Array ( [type] => c [weight] => 0.7 ) [2] => Array ( [type] => b [weight] => 0.6 ) [1] => Array ( [type] => d [weight] => 0.5 ) [0] => Array ( [type] => a [weight] => 0.5 ) )