- var_dump: documentation ( source)
- array_sum: documentation ( source)
<?php
class Foo {
public function op($op, $f) {
return $op($this->$f);
}
}
$a = new Foo();
$a->f = [1, 17, 23, 9, 12, 3, 9, 2, 7, 68]; 'avg';
var_dump($a->op(function($x) { return array_sum($x) / count($x); }, 'f'));