title: How to add element to JSON object using PHP?
body: <p>I have this JSON array, and i want to add another value to it using PHP.</p>
  
  <p>What would be the easiest way to add a ID and Name to this array using PHP.</p>
  
  <pre><code> [
     {
        "id":1,
        "name":"Charlie"
     },
     {
        "id":2,
        "name":"Brown"
     },
     {
        "id":3,
        "name":"Subitem",
        "children":[
           {
              "id":4,
              "name":"Alfa"
           },
           {
              "id":5,
              "name":"Bravo"
           }
        ]
     },
     {
        "id":8,
        "name":"James"
     }
  ]
  </code></pre>