2017-06-15 78 views
-1

我使用bit coin API生成比特幣地址。位硬幣API的變量返回完整數組,我如何獲得只有「available_balance」部分。 只有這一部分:如何在PHP中獲取數組的特定區域對象?

[available_balance] => 0.00138592 

代碼是:

$data=$block_io->get_address_balance(array('type' => 'received', 'addresses' => '3KHBGTRGFEgRHub8z5VUyT9L5ZUASpWZ')); 

function pr($data) 
{ 
    echo "<pre>"; 
    print_r($data); // or var_dump($data); 
    echo "</pre>"; 
} 

pr($data); 

輸出是:

stdClass Object 
(
    [status] => success 
    [data] => stdClass Object 
     (
      [network] => BTC 
      [available_balance] => 0.00138592 
      [pending_received_balance] => 0.00000000 
      [balances] => Array 
       (
        [0] => stdClass Object 
         (
          [user_id] => 5 
          [label] => Lalaa 
          [address] => 3KHBGTRGFEgRHub8z5VUyT9L5ZUASpWZ 
          [available_balance] => 0.00138592 
          [pending_received_balance] => 0.00000000 
         ) 

       ) 

     ) 

) 

回答

0

試試這個:

$res_arr=array(); 
foreach($data->data->balances as $value) { 
    $res_arr[] =$value->available_balance; 
} 
1

$stdClass->data->balances[0]->available_balance

是你如何獲取值

或者,如果你想外一級你這樣做:

$stdClass->data->available_balance

相關問題