title: Replace value in array/object php
body: <p>In the array/object below, how would I iterate through it and replace for instance SIEcat7 with test and SIEcat8 with test2. Trying below but have problems accessing the right level</p>
  
  <p>Code</p>
  
  <pre><code>foreach($data as $i =&gt; $item) {
     if ($i[0] = "SIEcat7") {
         $i[0] = "test";
     }  
  }
  </code></pre>
  
  <p>Object</p>
  
  <pre><code>stdClass Object
  (
      [SIEcat7] =&gt; stdClass Object
          (
              [text] =&gt; test1
              [amount] =&gt; 1 000.00
  
          )
  
      [SIEcat8] =&gt; stdClass Object
          (
              [text] =&gt; test2
              [amount] =&gt; 0.00
  
          )
  
  
  
  )
  </code></pre>
  
  <p>to become</p>
  
  <pre><code>stdClass Object
  (
      [test1] =&gt; stdClass Object
          (
              [text] =&gt; test1
              [amount] =&gt; 1 000.00
  
          )
  
      [test2] =&gt; stdClass Object
          (
              [text] =&gt; test2
              [amount] =&gt; 0.00
  
          )
  
  
  
  )
  </code></pre>