title: How to group JsonArray result content in json index
body: <p>In my JsonArray result, I want to put all the content in index <code>[{'data':{contenthere}}]</code></p>
  
  <p>Here is my code :</p>
  
  <pre><code>$data = [];
  $gr = []; //some data here
  
  foreach($gr as $g) {
      $data[] = [
          'id'   =&gt;  $g['id'],
          'name'   =&gt;  $g['name'],
          'phone'   =&gt;  $g['pĥone']
     ]
  }
  
  return $data;
  </code></pre>
  
  <p>return <code>$data</code> output : </p>
  
  <pre><code>string(249) "[
      {
          "id": "112",
          "name": "john",
          "phone": "XXXXXXXXX"
      },
      {
          "id": "213",
          "name": "mike",
          "phone": "XXXXXXXXX"
      },
      {
          "id": "246",
          "name": "jess",
          "phone": "XXXXXXXXX"
      },
  ]
  </code></pre>
  
  <p>cool, now I want to put all this in <code>['data']</code> so the result needed : </p>
  
  <pre><code>string(249) "[
      {
          "data": {
            {
              "id": "112",
              "name": "john",
              "phone": "XXXXXXXXX"
            },
            {
              "id": "213",
              "name": "mike",
              "phone": "XXXXXXXXX"
            },
            {
              "id": "246",
              "name": "jess",
              "phone": "XXXXXXXXX"
            },
          }
      }
  ]
  </code></pre>
  
  <p>As <a href="https://google.github.io/styleguide/jsoncstyleguide.xml#data.previous_/_data.previousLink" rel="nofollow noreferrer">Google JSON Style</a></p>
  
  <p>I tried the <code>$data[]['data']</code> but the <code>"data":</code> repeats in each object</p>
  
  <pre><code>foreach($gr as $g) {
          $data[]['data'] = ...
  </code></pre>
  
  <p>I thought do do <code>group_by</code> function but I think that there is a simple solution for that</p>