3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a; public function __construct($a) { $this->a = (int) $a; } public static function maxA(array $fooList) { return array_reduce($fooList, function($carry, self $item) { return ($carry == null || $item->a > $carry->a) ? $item : $carry; }); } } $fooList = [ new Foo(1), new Foo(5), new Foo(2), ]; var_dump(Foo::maxA($fooList));

preferences:
52.25 ms | 402 KiB | 5 Q