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