3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $sizes = array("BAR", "L", "XXXL", "INVALID", "M", "S", "FOO"); function compare($a, $b) { $sizeincrement = array("XS", "S", "M", "L", "XL", "XXL", "XXXL"); $a = array_search($a, $sizeincrement); $b = array_search($b, $sizeincrement); if($a == FALSE || $b == FALSE) return $a < $b; return $a > $b; } usort($sizes, "compare"); print_r($sizes);
Output for 7.0.0 - 7.1.0
Array ( [0] => S [1] => M [2] => L [3] => XXXL [4] => BAR [5] => INVALID [6] => FOO )
Output for 4.3.0 - 5.6.28
Array ( [0] => S [1] => M [2] => L [3] => XXXL [4] => FOO [5] => INVALID [6] => BAR )