3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public $a; public $b; public $c; public function __construct($a, $b, $c) { $this->a = $a; $this->b = $b; $this->c = $c; } } $arr = Array( A('a1235d', 'f', 'M'), A('a1235d', 'm', 'L'), A('a1235d', 'm', 'S'), A('a1234d', 'm', 'L'), A('a1234d', 'm', 'S'), A('a1236d', 'm', 'S'), A('a1236d', 'm', 'M'), A('a1234d', 'f', 'S'), A('a1236d', 'f', 'S'), A('a1236d', 'f', 'M'), A('a1235d', 'f', 'S'), A('a1234d', 'm', 'M'), A('a1235d', 'm', 'M'), A('a1234d', 'f', 'M'), A('a1235d', 'f', 'L'), A('a1236d', 'm', 'L'), A('a1236d', 'f', 'L'), A('a1234d', 'f', 'L') ); function sort_by_a($arr) { usort($arr, function($a, $b) { if ($a->a == $b->a) { return 0; } return ($a->a < $b->a) ? -1 : 1; }); return $arr; } function sort_by_b($arr) { usort($arr, function($a, $b) { if ($a->b == $b->b) { return 0; } return ($a->b < $b->b) ? -1 : 1; }); return $arr; } function sort_by_c($arr) { usort($arr, function($a, $b) { if ($a->c == $b->c) { return 0; } return ($a->c < $b->c) ? -1 : 1; }); return $arr; } $arr = sort_by_c($arr); $arr = sort_by_b($arr); $arr = sort_by_a($arr); var_dump($arr);
based on Gn8Jr
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function A() in /in/E94ha:15 Stack trace: #0 {main} thrown in /in/E94ha on line 15
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Fatal error: Call to undefined function A() in /in/E94ha on line 15
Process exited with code 255.