3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = new stdClass(); $a->foo = '*'; $b = new stdClass(); $b->foo = 'b'; $objects = array($a, $b); usort($objects, 'compareMethod'); var_dump($objects); function compareMethod($a,$b) { if ($a->foo === '*' || $b->foo === '*' ) { return 0; } return 1; }
Output for 7.0.0 - 7.2.0
array(2) { [0]=> object(stdClass)#1 (1) { ["foo"]=> string(1) "*" } [1]=> object(stdClass)#2 (1) { ["foo"]=> string(1) "b" } }
Output for 5.0.0 - 5.6.21
array(2) { [0]=> object(stdClass)#2 (1) { ["foo"]=> string(1) "b" } [1]=> object(stdClass)#1 (1) { ["foo"]=> string(1) "*" } }
Output for 4.3.0 - 4.4.9
array(2) { [0]=> object(stdClass)(1) { ["foo"]=> string(1) "b" } [1]=> object(stdClass)(1) { ["foo"]=> string(1) "*" } }