JSON代碼 -如何在PHP解析JSON對象
"days": [
{
"day-code": "SUN",
"runs": "Y"
},
{
"day-code": "MON",
"runs": "Y"
},
{
"day-code": "TUE",
"runs": "Y"
},
{
"day-code": "WED",
"runs": "Y"
},
{
"day-code": "THU",
"runs": "Y"
},
{
"day-code": "FRI",
"runs": "Y"
},
{
"day-code": "SAT",
"runs": "Y"
}
]
通過使用下面的代碼從PHP
檢索 「天碼」 -
days[0]['day-code'];
OR
days[0][0];
php error -
Fatal error: Uncaught Error: Cannot use object of type stdClass as array
任何人都可以幫助我解決這個問題。
試'json_decode()' – Afsar
請參考https://www.w3schools.com/js/js_json_php.asp –
我已經解析了它之後,我用於回顧對象。我也使用(天[0] - >日代碼),但沒有這個工程。我認爲問題出現在日代碼之間的( - )中。 – user7865403