title: Generate JSON Object for Mysql Tier Table (PHP)
body: <p>Straight to point i have 3 tables like following -</p>
  
  <p><strong>QTY Types Table</strong></p>
  
  <pre>
  --------------------
  | ID  |  QTY types |
  |  1  |  1         |
  |  2  |  2-4       |
  |  3  |  5-9       |
  |  4  |  10-24     |
  |  5  |  25+       |
  --------------------
  </pre>
  
  <p><strong>Poster Size Table</strong></p>
  
  <pre>
  -----------------------
  | ID  |  Poster Size  |
  +-----+---------------+
  |  1  |  A4           |
  |  2  |  A3           |
  |  3  |  A2           |
  |  4  |  A1           |
  |  5  |  A0           |
  -----------------------
  </pre>
  
  <p><strong>Price table (based on Qty ID- column title)</strong></p>
  
  <pre>
  --------------------------------------------------------------------------------
  | qty_id_1  |  qty_id_2  |  qty_id_3  |  qty_id_4  |  qty_id_5  |  poster_size |
  +-----------+------------+------------+------------+------------+--------------+
  |     4     |    3.5     |   2.75     |   3.25     |         3  |            1 |
  |     6     |    5.5     |      4     |   4.75     |       4.5  |            2 |
  |    12     |    9.5     |    6.5     |    8.5     |         8  |            3 |
  |    18     |     16     |   10.5     |     14     |      12.5  |            4 |
  |    34     |     33     |     25     |     31     |        28  |            5 |
  --------------------------------------------------------------------------------
  </pre>
  
  <p>I just wanted to Generate Price According to User Input for example if user selects <code>Qty.id=2 Poster_size.id=3</code> so answer will be <strong>$9.5</strong>. </p>
  
  <p>All of this data are static so after that i just wanted to generate JSON file 
  using <code>fwrite (php)</code> something like this </p>
  
  <pre>
  
      {
          "qty_1":{
              "poster_size_1":[
                  {
                      "price":4
                  }
              ],
              "poster_size_2":[
                  {
                      "price":6
                  }
              ],
              "poster_size_3":[
                  {
                      "price":12
                  }
              ],
              "poster_size_4":[
                  {
                      "price":18
                  }
              ],
              "poster_size_5":[
                  {
                      "price":34
                  }
              ]
          },
          "qty_2":{
              "poster_size_1":[
                  {
                      "price":3.5
                  }
              ],
              "poster_size_2":[
                  {
                      "price":5.5
                  }
              ],
              "poster_size_3":[
                  {
                      "price":9.5
                  }
              ],
              "poster_size_4":[
                  {
                      "price":16
                  }
              ],
              "poster_size_5":[
                  {
                      "price":33
                  }
              ]
          }
      }
  
  </pre>
  
  <p>By this i can easily access <code>obj.qty_1.poster_size_3.price</code> as <strong>$9.5</strong>. </p>
  
  <p>How can i populate JSON file like this or is there any alternate way to populate different JSON structure to get my required data. (im new to JSON objects)</p>
  
  <p>Help Appreciated | Thanks in Advance  </p>
  
  <p><a href="https://gist.github.com/joeljerushan/686454b52688f3d4d3b5319cc3b68d3c" rel="nofollow noreferrer">Please Check this my sample PHP file to generate JSON</a></p>