title: How do i add a name: value pair to an existing mysql stored json object
body: <p>how do i add the new attribute to a json object i have stored in a mysql table column? now i have json_encode data stored like: </p>
  
  <pre><code>"1":{"lastname":"blah","firstname":"R.A.","function":"Manager","email":"test@hotmail.com","barcode":"33432799181"}  
  </code></pre>
  
  <p>and i like to add a new data pair, visted:0 which i want to update as soon as a person has been visited.</p>
  
  <pre><code>"1":{"lastname":"blah","firstname":"R.A.","function":"Manager","email":"test@hotmail.com","barcode":"33432799181", "visited":"0"}
  </code></pre>
  
  <p>How do i push an element to the existing json data?</p>
  
  <pre><code>$jsondataTmp = json_decode($core,true);
  $custom = array('visited'=&gt;'0');
  $jsondataTmp[] = $custom;
  </code></pre>
  
  <p>but it adds an array and not within each</p>
  
  <pre><code>  [1] =&gt; Array
          (
              [lastname] =&gt; blah
              [firstname] =&gt; R.A.
              [function] =&gt; Manager
              [email] =&gt; test@hotmail.com
              [barcode] =&gt; 33432799181
          )
  
      [2] =&gt; Array
          (
             [lastname] =&gt; blah
              [firstname] =&gt; R.A.
              [function] =&gt; Manager
              [email] =&gt; test@hotmail.com
              [barcode] =&gt; 33432799181
          )
  
      [3] =&gt; Array
          (
              [visited] =&gt; 0
          )
  </code></pre>
  
  <p>and not </p>
  
  <pre><code>[2] =&gt; Array
              (
                 [lastname] =&gt; blah
                  [firstname] =&gt; R.A.
                  [function] =&gt; Manager
                  [email] =&gt; test@hotmail.com
                  [barcode] =&gt; 33432799181
  [visited] =&gt; 0
              )
  </code></pre>