3v4l.org

run code in 300+ PHP versions simultaneously
<?php // SETUP CODE class A { function __construct($val) { $this->val = $val; } } $objs = [ new A(3), new A(5), new A(2), ]; // AMAZING max_by IMPL :P $res = array_reduce($objs, function ($c, $o) { $m = max($o->val, $m); return $o->val == $m; }); var_dump($res);

preferences:
44.45 ms | 402 KiB | 5 Q