PHP: Get data from JSON? -
this question has answer here:
- how extract data json php? 2 answers
- how can parse json file php? 14 answers
i'm trying data json.
the json looks this:
{ "object": "balance", "available": [ { "currency": "aud", "amount": 0, "source_types": { "card": 0 } } ], "livemode": false, "pending": [ { "currency": "aud", "amount": 37706, "source_types": { "card": 37706 } } ] }{ "object": "balance", "available": [ { "currency": "aud", "amount": 0, "source_types": { "card": 0 } } ], "livemode": false, "pending": [ { "currency": "aud", "amount": 37706, "source_types": { "card": 37706 } } ] }{ "object": "balance", "available": [ { "currency": "aud", "amount": 0, "source_types": { "card": 0 } } ], "livemode": false, "pending": [ { "currency": "aud", "amount": 37706, "source_types": { "card": 37706 } } ] } all need there available balance.
i tried code output of code {{{
this code:
$amount = $balancearr['balance']['available'][0]['amount']; echo $amount; note $balancearr json.
could please advice on issue?
any appreciated.
thanks in advance.
you need json_decode output, default objects, if
$balancearr = json_decode($balancearr, true); above code posted, work
your json incorrectly formed also
$balancearr[0]['available'][0]['amount'] will work if json string valid (needs commas , array wrapping whole thing)
Comments
Post a Comment