[ create a new paste ] login | about

Link: http://codepad.org/Q3wernBH    [ raw code | output | fork ]

PHP, pasted on Apr 8:
<?php
$a = '{"product": [{
    "title":"Product One",
    "price":"Price One",
    "desc":"Description One",
    "image": [{
        "img":"image 1 1"
    },{
        "img":"image 1 2"
    },{
        "img":"image 1 3"
    }]
}, {
    "title":"Product Two",
    "price":"Price Two",
    "desc":"Description Two",
    "image": [{
        "img":"image 2 1"
    },{
        "img":"image 2 2"
    },{
        "img":"image 2 3"
    }]
}]
}';
$product = json_decode($a, true);
foreach($product['product'] as $value) {
        foreach($value["image"] as $image) {
            echo "Image: " .$image['img'] . "\n"; 
        }

  }


Output:
1
2
3
4
5
6
Image: image 1 1
Image: image 1 2
Image: image 1 3
Image: image 2 1
Image: image 2 2
Image: image 2 3


Create a new paste based on this one


Comments: