Welcome Guest, Not a member yet? Register   Sign In
Restfull JSON Array Help
#6

(This post was last modified: 04-08-2016, 01:18 AM by paulkd.)

Hope this helps.

PHP Code:
$json '
{
    "code": "VET002",
    "store": "DBNG0024",
    "items": [{
        "code": "1",
        "descr": "Yoghurt",
        "value": "66",
        "qty": "3",
        "dept": "1"
    }, {
        "code": "25",
        "descr": "Red Bull",
        "value": "44",
        "qty": "2",
        "dept": "2"
    }, {
        "code": "23",
        "descr": "Lipton Lemon",
        "value": "72",
        "qty": "6",
        "dept": "2"
    }]
}
'
;

$arr json_decode($jsontrue);
$total 0;

?>

<p>Store: <?php echo $arr['store']; ?></p>
<p>Code: <?php echo $arr['code']; ?></p>
<p>Items:</p>
<ul>
    <?php foreach($arr['items'] as $arr2): ?>
        <li>
            <?php foreach($arr2 as $itemKey => $itemValue): ?>
                <?php echo '<b>'.$itemKey.'</b>: '.$itemValue?>
            <?php endforeach; ?>
        </li>
        <?php $total += $arr2['qty']; ?>
    <?php endforeach; ?>
</ul>
<p>Total Qty: <?php echo $total?></p> 
Reply


Messages In This Thread
Restfull JSON Array Help - by BeVirtual - 04-07-2016, 12:03 AM
RE: Restfull JSON Array Help - by EricP - 04-07-2016, 02:44 AM
RE: Restfull JSON Array Help - by BeVirtual - 04-07-2016, 12:20 PM
RE: Restfull JSON Array Help - by Tpojka - 04-07-2016, 05:11 PM
RE: Restfull JSON Array Help - by BeVirtual - 04-07-2016, 10:00 PM
RE: Restfull JSON Array Help - by paulkd - 04-08-2016, 01:17 AM
RE: Restfull JSON Array Help - by BeVirtual - 04-08-2016, 01:35 AM
RE: Restfull JSON Array Help - by paulkd - 04-08-2016, 02:11 AM
RE: Restfull JSON Array Help - by BeVirtual - 04-08-2016, 07:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB