3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $list = array( array ( 'excluded_by_default' => false, 'name' => 'Erik1' ), array ( 'excluded_by_default' => true, 'name' => 'Erik2' ), array ( 'excluded_by_default' => false, 'name' => 'Erik3' ) ); //Sort by excluded by default. function cmp($a, $b) { $test = ($a['excluded_by_default'] === $b['excluded_by_default']) ? -1 : 1; echo $test; return ($a['excluded_by_default'] === $b['excluded_by_default']) ? -1 : 1; } usort($list, "cmp"); var_dump($list);
Output for 7.0.0 - 7.1.0
11-1array(3) { [0]=> array(2) { ["excluded_by_default"]=> bool(true) ["name"]=> string(5) "Erik2" } [1]=> array(2) { ["excluded_by_default"]=> bool(false) ["name"]=> string(5) "Erik1" } [2]=> array(2) { ["excluded_by_default"]=> bool(false) ["name"]=> string(5) "Erik3" } }
Output for 4.3.0 - 5.6.28
11array(3) { [0]=> array(2) { ["excluded_by_default"]=> bool(false) ["name"]=> string(5) "Erik1" } [1]=> array(2) { ["excluded_by_default"]=> bool(true) ["name"]=> string(5) "Erik2" } [2]=> array(2) { ["excluded_by_default"]=> bool(false) ["name"]=> string(5) "Erik3" } }