📌  相关文章
📜  如何在 php 代码示例中从 json 数组中获取数据

📅  最后修改于: 2022-03-11 14:53:58.930000             🧑  作者: Mango

代码示例6
$json = '
{
    "type": "donut",
    "name": "Cake",
    "toppings": [
        { "id": "5002", "type": "Glazed" },
        { "id": "5006", "type": "Chocolate with Sprinkles" },
        { "id": "5004", "type": "Maple" }
    ]
}';

$yummy = json_decode($json, true);

echo $yummy['toppings'][2]['type']; //Maple