title: assigining new key value pair to stdclass object in foreach php
body: <p>Im fetching a pdo object with data from the database. now when i foreach this data I want to add extra key values but this doest work.</p>
  
  <pre><code>            foreach ($deliveryCompanies as $k=&gt;$v) {
              $k-&gt;test = 'test';
          }
  </code></pre>
  
  <p>this returns
      Type: ErrorException
       Code: 2
       Message: Attempt to assign property of non-object</p>
  
  <p>the object looks like this</p>
  
  <pre><code>    Array
  (
      [0] =&gt; stdClass Object
          (
              [delivery_id] =&gt; 2
              [delivery_location_id] =&gt; 34
              [delivery_category_id] =&gt; 1
          )
  
      [1] =&gt; stdClass Object
          (
              [delivery_id] =&gt; 4
              [delivery_location_id] =&gt; 34
              [delivery_category_id] =&gt; 1
          )
  
  )
  1
  </code></pre>