I have an array that stores some Employee Objects ie.
var $this->employeeArray = array();
$this->employeeArray[] = $empObjectA;
$this->employeeArray[] = $empObjectB;
...
which Employee object has id, firstName, lastName etc. I also have a function to search for the employee object that with certain ID. ie:
public function searchArrayByID($id) {
$targetObject = null;
foreach($this->employeeArray as $e) {
if ($id == $e->id) {
$targetObject = $e;
break;
}
}//foreach
return $targetObject;
}
but when I do:
$targetEmployee = $this->searchArrayByID(1);
$targetEmployee->firstName = "someOtherName";
and do a
print_r($this->employeeArray);
that object inside the Array is not being changed.