我试图从以下 JSON 中提取价格,但似乎无法弄清楚如何引用实际值:
{"cards": [ { "high": "0.73", "volume": 1, "percent_change": "-2.67", "name": "Lightning Bolt", "url": "http://blacklotusproject.com/cards/Revised+Edition/Lightning+Bolt/", "price": "0.73", "set_code": "3ED", "average": "0.73", "change": "-0.02", "low": "0.73"}], "currency": "USD" }
到目前为止,我已经得到了这个代码,它进入了卡片数组,但我不确定如何走得更远——我尝试过的每一次尝试都返回 null。
$json = file_get_contents($url); $data = json_decode($json, TRUE);
echo var_dump($data[cards]);
有人可以阐明我需要做什么吗?