-1
解決方案如何從JSON獲得價格總
要想從環總價在JSON我們需要在下面的代碼使用$tot += +$data['price'].",";
$arr = '[{
"id": 1,
"name": "A green door",
"price": 11,
"tags": ["home", "green"]
},
{
"id": 2,
"name": "A green door",
"price": 15,
"tags": ["home", "green"]
},
{
"id": 3,
"name": "A green door",
"price": 10,
"tags": ["home", "green"]
}]';
//print_r($arr);
$arr = json_decode($arr,TRUE);
foreach ($arr as $data)
{
$tot += +$data['price'].",";
}
echo "Total = ".rtrim($tot,',');
在哪裏的問題? – kennasoft
我已經給這個問題的答案和問題是:如何從JSON獲得價格總 – ikppramesh
你需要去看看如何使用該網站。這不是如何回答你自己的問題。 http://stackoverflow.com/help/self-answer – kennasoft