title: Yii2 return JSON format with array inside an array
body: <p>I am trying to get these data below,</p>
  
  <p><strong>Table relations:</strong></p>
  
  <p>people(one) &lt;---> (many) people_info (one) &lt;---> (many) people_contact</p>
  
  <p>in the following format,</p>
  
  <pre><code>people: {
      p_id: 10,
      p_price: 3.99,
      people_info : [
          {
              pl_id: 3,
              pl_state: 2,
              pl_district: 6,
              pl_latitude: 6.323434,
              pl_longitude: 108.23499,
              people_contact: [
                  {
                      plc_id: 2
                  },
                  {
                      plc_id: 1
                  }
              ]
          },
          {
              pl_id: 2,
              pl_state: 7,
              pl_district: 12,
              pl_latitude: 6.000434,
              pl_longitude: 108.9910003,
              people_contact: [
                  {
                      plc_id: 5
                  },
                  {
                      plc_id: 9
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>Currently with these controller codes,</p>
  
  <pre><code>    class PeopleController extends Controller
  {
  public function actionPeople($params){
      Yii::$app-&gt;response-&gt;format = Response::FORMAT_JSON;
  
  ....//some other codes//.....       
          $people= People::find()-&gt;select(['p_id', 'p_price'] )-&gt;where(['p_id' =&gt; $itemId])-&gt;one();
          $info= PeopleContact::find()-&gt;with(['plPeople'])-&gt;asArray([])-&gt;all();
  
       return array(
          'people' =&gt; $people,
          'info' =&gt; $info,
       );
  }
  
   }
  </code></pre>
  
  <p>I got these,</p>
  
  <pre><code>"people": {
      "p_id": "3",
      "p_price": "32.42"
  }, "locations": [{
      "pl_id": "1",
      "pl_people": "3",
      "pl_title": "",
      "pl_latitude": "6.16438700000000000000",
      "pl_longitude": "102.28314649999993000000",
      "pl_place": null,
      "pl_premise": null,
      "pl_street": "1",
      "pl_area": "1",
      "pl_postcode": "1",
      "pl_district": "1",
      "pl_state": "3",
      "pl_country": 1,
      "place": null,
      "premise": null,
      "street": null,
      "area": null,
      "postcode": null,
      "district": null,
      "state": null,
      "country": "United Kingdom",
      "contacts": [{
          "plc_name": "joe",
          "plc_phone": "123456",
          "plc_email": null
      }]
  }]
  }
  </code></pre>
  
  <p>How do I achieve it in the format mentioned at the top?</p>