PHP Decoding Array Within Json Object -
i stuck json data:
i have info in variable:
$mydata= '{"success":true,"data":[{"sku":203823,"issoldout":false,"isshowdiscount":false,"discount":0,"currencycode":"usd","currencysymbol":"us$","price":"10.20","listprice":"","adddate":"4/23/2013"}]}';
i have managed tell if success true or not doing this:
$obj = json_decode($mydata, true); if ($obj['success'] != 1) { print 'does not exist<br />'; } else{ print $obj['success']."<br/>"; }
where echo $obj['success'];
equal 1 if true , 0 if false.
what getting me stuck how @ keys in "data":[] array.
i tried print $obj['data'][0];
, print $obj['data']['sku'];
both returned nothing.
any ideas on how info out welcomed.
$data
array so:
echo $obj['data'];
should print "array"
echo $obj['data'][0]['sku'];
should print "203823"
Comments
Post a Comment