我使用引導數據表來顯示錶中API的數據。下面是數據:使用PHP將JSON輸出到HTML表格
{
"response_status": {
"status_code": 0,
"status_message": [
{
"reg_number": "123",
"company": "Company A",
"office": "Orlando",
"phone_number": "28122312345",
"postal_address": "000",
"postal_code": "000"
},
{
"reg_number": "552",
"company": "Company B",
"office": "Miami",
"phone_number": "28122312345",
"postal_address": "000",
"postal_code": "000"
},
{
"reg_number": "154",
"company": "Company C",
"office": "San Francisco",
"phone_number": "28122312345",
"postal_address": "000",
"postal_code": "000"
}
]
}
}
我需要的結果輸出HTML,因爲這:
<table>
<thead>
<tr>
<th>Reg No</th>
<th>Company</th>
<th>Office</th>
<th>Phone Number</th>
<th>Postal Address</th>
<th>Postal Code</th>
</tr>
</thead>
<tbody>
<tr>
<td>123</td>
<td>Company A</td>
<td>San Francisco</td>
<td>28122312345</td>
<td>000</td>
<td>000</td>
</tr>
<tr>
<td>552</td>
<td>Company B</td>
<td>Miami</td>
<td>28122312345</td>
<td>000</td>
<td>000</td>
</tr>
<tr>
<td>154</td>
<td>Company C</td>
<td>San Francisco</td>
<td>28122312345</td>
<td>000</td>
<td>000</td>
</tr>
</tbody>
<table>
有沒有一種方法可以讓我通過JSON體循環和自動輸出環路的所有字段"status_message": [];
使用PHP的foreach循環到我的表?
可能的重複[如何從JSON使用PHP提取數據?](http://stackoverflow.com/questions/29308898/how-do -i-extract-data-from-json-with-php) –