1 回答
TA贡献1921条经验 获得超9个赞
我假设您将json数据放入此变量$ jsonData中
<?php
echo "jsondata=>".$jsonData='{
"creation":"12/01/2019",
"status":"paid",
"price":0.0,
"items":[
{
"name":"Math books",
"amount":"2"
},
{
"name":"Skates adult",
"amount":"1"
},
{
"name":"Tools",
"amount":"8"
}
]
}';
$data1 = json_decode($jsonData, TRUE);
echo "<pre>";
print_r($data1);
foreach ($data1 as $key => $value1) {
if($key=='creation'){
echo $value1."<br>";
}
if($key=='status'){
echo $value1."<br>";
}
if($key=='price'){
echo $value1."<br>";
}
if($key=='items'){
foreach ($value1 as $key1 => $value_deta) {
print_r($value_deta);
}
}
}
- 1 回答
- 0 关注
- 142 浏览
添加回答
举报