title: Join Table To a nested array [PHP/MYSQL]
body: <p>How to select join multiple tables and get it in a nested array easily?</p>
  
  <p>For Example</p>
  
  <pre><code>Table 1 -School: SchoolID, SchoolName,PrincipalID
  Talbe 2 - Principal: PrincipalID,PrincipalName
  </code></pre>
  
  <p>I want to get a nested array in PHP like</p>
  
  <pre><code>"School": [
              {
                  "SchoolID": "7",
                  "SchoolName": "New",
                  "Principal": {
                        "PrincipalID":"1",
                        "PrincipalName":"James"
                  }
              }
  </code></pre>
  
  <p>The problem is, how to get the nested array use a automatic way instead of specifying each field and add it into a array manually? without even kowning the actual field names, just nesting multiple tables into a nested array.</p>