超级嵌套的json数组

Please help me pull this into a php variable... I have the following json decoded code:

  "account_id":12345,
  "name":"Example account",
  "state":"active",
     "balances":[
        {
          "currency":"USD",
          "balance":390.50,
          "incoming_pending_amount":635.30,
          "outgoing_pending_amount":210.00,
          "reserved_amount":0,
          "disputed_amount":0,
          "withdrawal_period":"daily",
          "withdrawal_next_time":1370112217,
          "withdrawal_bank_name":"WellsFargo XXXXX3102"
        }

I want to bring out the balance into a php variable and am not sure how to.

when I do

foreach ($accounts as $a)

I can echo $a->account_id just fine - but when I try to echo $a->balances->balance it does not give me the 390.50 for the result...

any kind of help I can get on this is great appreciated!

In your json, balance is also an array so you need to have one more loop to traverse balances objects like:

foreach($accounts as $a){
    echo $a->account_id;
    echo $a->name;
    echo $a->stat;

    foreach($a->balances as $b) //loop if you want to print all balances
    {
       echo $b->currency;
       echo $b->balance;
       ...
       ...            
    } 

    // echo $a->balances[0]->balance;  //a single statement if you want to access just first balance object
}