3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Spaceship { public $name; public $maxSpeed; public function __construct($name, $maxSpeed) { $this->name = $name; $this->maxSpeed = $maxSpeed; } } $spaceships = [ new Spaceship('Rebel Transport', 20), new Spaceship('Millenium Falcon', 80), new Spaceship('X-Wing Starfighter', 80), new Spaceship('TIE Bomber', 60), new Spaceship('TIE Fighter', 100), new Spaceship('Imperial Star Destroyer', 60), ]; // Sort the spaceships by name (in ascending order) usort($spaceships, function ($ship1, $ship2) { return $ship1->name <=> $ship2->name; });

preferences:
37.16 ms | 402 KiB | 5 Q