- var_dump: documentation ( source)
- array_filter: documentation ( source)
<?php
class A {
protected $name;
public function __construct($name)
{
$this->name = $name;
}
public function isTest()
{
return $this->name === 'test';
}
}
$things = array();
$things[] = new A('aaa');
$things[] = new A('bbb');
$things[] = new A('test');
$things[] = new A('ddd');
var_dump(array_filter($things, array('isTest', '$this')));