title: Illegal string offset 'id' while for loop php
body: <p>i have this issue and i think is easy to fix for this but i can't handle how to do this ;x</p>
  <p>EDIT: I'm know why im getting this error, $user-&gt;items[$i] is a string but still... idk how i can fix it</p>
  <p>The part of code where im getting the error looks like this</p>
  <pre><code>                            for($i=0;$i &lt;= 10; $i++){
                              if($user-&gt;items[$i][&quot;id&quot;] != $item-&gt;id){
                                  $user-&gt;items = json_encode(array_merge($user-&gt;items, $drop_item));
                              } else {
                                  $user-&gt;items = json_encode(array_merge($user-&gt;items[$i], ['amount' =&gt; 99]));
                              }
                          }
  </code></pre>
  <p>and when im running my code im gatting this error Illegal string offset 'id'</p>
  <p>the array looks like this if it matters</p>
  <pre><code>[{&quot;id&quot;:12,&quot;amount&quot;:1,&quot;upgrade&quot;:0},{&quot;id&quot;:13,&quot;amount&quot;:1,&quot;upgrade&quot;:0}]
  </code></pre>