<?php
class Test
{
public $name;
}
$test1 = new Test;
$test1->name = 'hello';
$test2 = new Test;
$test2->name = 'world';
$arr = array($test1, $test2);
foreach ($arr as $test) {
if ($test->name == 'hello') unset($test); /* Так только работает:
if ($test->name == 'hello') {
$index = array_search($test, $arr);
unset($arr[$index]);
}*/
}
PD9waHAKCmluaV9zZXQoJ2Rpc3BsYXlfZXJyb3JzJywgdHJ1ZSk7CmVycm9yX3JlcG9ydGluZyhFX0FMTCk7CgpjbGFzcyBUZXN0CnsKICAgIHB1YmxpYyAkbmFtZTsKfQoKJHRlc3QxID0gbmV3IFRlc3Q7CiR0ZXN0MS0+bmFtZSA9ICdoZWxsbyc7CgokdGVzdDIgPSBuZXcgVGVzdDsKJHRlc3QyLT5uYW1lID0gJ3dvcmxkJzsKCiRhcnIgPSBhcnJheSgkdGVzdDEsICR0ZXN0Mik7CnVuc2V0KCR0ZXN0MSk7Cgpmb3JlYWNoICgkYXJyIGFzICR0ZXN0KSB7CglpZiAoJHRlc3QtPm5hbWUgPT0gJ2hlbGxvJykgdW5zZXQoJHRlc3QpOwogICAgLyog0KLQsNC6INGC0L7Qu9GM0LrQviDRgNCw0LHQvtGC0LDQtdGCOgogICAgaWYgKCR0ZXN0LT5uYW1lID09ICdoZWxsbycpIHsKICAgIAkkaW5kZXggPSBhcnJheV9zZWFyY2goJHRlc3QsICRhcnIpOwogICAgCXVuc2V0KCRhcnJbJGluZGV4XSk7CiAgICB9Ki8KfQoKdmFyX2R1bXAoJGFycik7