我不知道怎么稱呼這個看起來像陣列的物件。但是當我嘗試訪問 PHP 中的元素時,我不能。
{
"message":"authenticated",
"data": {"id":713,"name":"Jamal","email":"[email protected]","role":"user"}
}
我想訪問這樣的元素。$array['message']=> 期望結果被“認證”。請幫忙
uj5u.com熱心網友回復:
$JSON = file_get_contents('UserData.json'); // Parsing JSON from file. You can use your own way.
$Array = json_decode($JSON, true); // JSON (string) to Array
echo $Array["message"]; // Output: authenticated
echo $Array["data"]["id"]; // Output: 713
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/425112.html
