$url2 = "http://www.website.com/test.json";
$json2 = file_get_contents($url2);
$data2 = json_decode($json2);
foreach($data2 as $mydata2) {
$product_discount = $mydata2->applied_discounts;
var_dump($product_discount);
}
这是返回:
array(1) {
[0]=> object(stdClass)#2 (2) {
["id"]=> string(6) "coupon"
["amount"]=> float(9.99)
}
}
我只想返回“9.99”的金额
我试过 $product_discount[0]['amount'],但这似乎不对??