Skip to main content
nest is not the right tag
Link
Martijn Laarman
  • 13.5k
  • 47
  • 64
Not formatted piece of code (var_dump output)
Source Link
$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);
}

This is returning:

array(1) { [0]=> object(stdClass)#2 (2) { ["id"]=> string(6) "coupon" ["amount"]=> float(9.99) } }

array(1) {
    [0]=> object(stdClass)#2 (2) {
        ["id"]=> string(6) "coupon"
        ["amount"]=> float(9.99)
    }
}

I want to return just the amount of "9.99"

I tried $product_discount[0]['amount'], but that doesn't seem to be right??

$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);
}

This is returning:

array(1) { [0]=> object(stdClass)#2 (2) { ["id"]=> string(6) "coupon" ["amount"]=> float(9.99) } }

I want to return just the amount of "9.99"

I tried $product_discount[0]['amount'], but that doesn't seem to be right??

$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);
}

This is returning:

array(1) {
    [0]=> object(stdClass)#2 (2) {
        ["id"]=> string(6) "coupon"
        ["amount"]=> float(9.99)
    }
}

I want to return just the amount of "9.99"

I tried $product_discount[0]['amount'], but that doesn't seem to be right??

Source Link
Brian V.
  • 37
  • 1
  • 8

nested array with json

$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);
}

This is returning:

array(1) { [0]=> object(stdClass)#2 (2) { ["id"]=> string(6) "coupon" ["amount"]=> float(9.99) } }

I want to return just the amount of "9.99"

I tried $product_discount[0]['amount'], but that doesn't seem to be right??