3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Customer { public $score; public function __construct($score) { $this->score = $score; } } $customers = []; $customers[] = new Customer(13); $customers[] = new Customer(11); $customers[] = new Customer(14); $customers[] = new Customer(10); $customers[] = new Customer(12.5); usort($customers, function($a, $b) { return $b->score - $a->score; }); var_dump($customers);
Output for 7.0.0 - 7.2.0
array(5) { [0]=> object(Customer)#3 (1) { ["score"]=> int(14) } [1]=> object(Customer)#1 (1) { ["score"]=> int(13) } [2]=> object(Customer)#5 (1) { ["score"]=> float(12.5) } [3]=> object(Customer)#2 (1) { ["score"]=> int(11) } [4]=> object(Customer)#4 (1) { ["score"]=> int(10) } }
Output for 5.4.11 - 5.6.28
array(5) { [0]=> object(Customer)#3 (1) { ["score"]=> int(14) } [1]=> object(Customer)#5 (1) { ["score"]=> float(12.5) } [2]=> object(Customer)#1 (1) { ["score"]=> int(13) } [3]=> object(Customer)#2 (1) { ["score"]=> int(11) } [4]=> object(Customer)#4 (1) { ["score"]=> int(10) } }
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/BOdr3 on line 10
Process exited with code 255.