<?php
class Foo {
public $name;
public $type;
public function __construct($name, $type) {
$this->name = $name;
$this->type = $type;
}
}
$array[] = new Foo('first', 0);
$array[] = new Foo('second', 0);
$array[] = new Foo('third', 1);
$array[] = new Foo('fourth', 1);
$filter = array_filter($array, function($f) {return ($f->type == 1);});
PD9waHAKY2xhc3MgRm9vIHsKCXB1YmxpYyAkbmFtZTsKCXB1YmxpYyAkdHlwZTsKIAoJcHVibGljIGZ1bmN0aW9uIF9fY29uc3RydWN0KCRuYW1lLCAkdHlwZSkgewoJCSR0aGlzLT5uYW1lID0gJG5hbWU7CgkJJHRoaXMtPnR5cGUgPSAkdHlwZTsKCX0KfQoKIAokYXJyYXlbXSA9IG5ldyBGb28oJ2ZpcnN0JywgMCk7CiRhcnJheVtdID0gbmV3IEZvbygnc2Vjb25kJywgMCk7CiRhcnJheVtdID0gbmV3IEZvbygndGhpcmQnLCAxKTsKJGFycmF5W10gPSBuZXcgRm9vKCdmb3VydGgnLCAxKTsKCiRmaWx0ZXIgPSBhcnJheV9maWx0ZXIoJGFycmF5LCBmdW5jdGlvbigkZikge3JldHVybiAoJGYtPnR5cGUgPT0gMSk7fSk7CiAKJHJlc3VsdCA9IGFycmF5X2RpZmYoJGFycmF5LCAkZmlsdGVyKTsKCnByaW50X3IoJHJlc3VsdCk7