- var_dump: documentation ( source)
- array_filter: documentation ( source)
- max: documentation ( source)
<?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_filter($objs, function ($o) {
static $m;
var_dump($m);
$m = max($o->val, $m);
return $o->val == $m;
});
//print_r($res);