我想解碼JSON數據到PHP然後輸出到網站。如果我有以下幾點:json,php - 從數組輸出字符串
{
"name": "josh",
"type": "human"
{
我可以做到這一點(PHP內),以顯示或輸出我type
:
$file = "path";
$json = json_decode($file);
echo $json["type"]; //human
所以,如果我有以下幾點:
{
"name": "josh",
"type": "human",
"friends": [
{
"name": "ben",
"type": "robot"
},
{
"name": "tom",
"type": "alien"
}
],
"img": "img/path"
}
我怎樣才能輸出type
我朋友ben
是什麼?
我們鼓勵你使用'jq'那最適合這種工作。你可能想在類似的問題上檢查我的[\ [other answer \]](http://stackoverflow.com/a/39233446/1620779)。 – sjsam