fork download
  1. <?php
  2.  
  3. class Engineer {
  4. public $name;
  5. public function __construct($n) {
  6. $this->name = $n;
  7. }
  8. }
  9.  
  10. $engineers = array();
  11. for ($i=0; $i<3; $i++) {
  12. $engineers[] = new Engineer('BlueCollar'.$i);
  13. }
  14.  
  15. $ex = $engineers[2];
  16.  
  17. foreach($engineers as $index=>$hireHim) {
  18. // echo $hireHim->name . "\n";
  19. unset($hireHim);
  20. unset($engineers[$index]);
  21. // var_dump($hireHim);
  22. }
  23. var_dump($ex);
  24. var_dump($engineers);
  25.  
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
object(Engineer)#3 (1) {
  ["name"]=>
  string(11) "BlueCollar2"
}
array(0) {
}