PHP: Get data from JSON? -


this question has answer here:

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

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -