📜  php 返回 json - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:49.105000             🧑  作者: 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