<?php
class Engineer {
public $name;
public function __construct($n) {
$this->name = $n;
}
}
for ($i=0; $i<3; $i++) {
$engineers[] = new Engineer('BlueCollar'.$i);
}
$ex = $engineers[2];
foreach($engineers as $index=>$hireHim) {
// echo $hireHim->name . "\n";
unset($engineers[$index]); // var_dump($hireHim);
}
PD9waHAKCmNsYXNzIEVuZ2luZWVyIHsKCXB1YmxpYyAkbmFtZTsKCXB1YmxpYyBmdW5jdGlvbiBfX2NvbnN0cnVjdCgkbikgewoJCSR0aGlzLT5uYW1lID0gJG47Cgl9Cn0KCiRlbmdpbmVlcnMgPSBhcnJheSgpOwpmb3IgKCRpPTA7ICRpPDM7ICRpKyspIHsKCSRlbmdpbmVlcnNbXSA9IG5ldyBFbmdpbmVlcignQmx1ZUNvbGxhcicuJGkpOwp9CgokZXggPSAkZW5naW5lZXJzWzJdOwoKZm9yZWFjaCgkZW5naW5lZXJzIGFzICRpbmRleD0+JGhpcmVIaW0pIHsKLy8JZWNobyAkaGlyZUhpbS0+bmFtZSAuICJcbiI7Cgl1bnNldCgkaGlyZUhpbSk7Cgl1bnNldCgkZW5naW5lZXJzWyRpbmRleF0pOwovLwl2YXJfZHVtcCgkaGlyZUhpbSk7Cn0KdmFyX2R1bXAoJGV4KTsKdmFyX2R1bXAoJGVuZ2luZWVycyk7Cg==