2013-12-12 77 views
-1

我正在使用MtGOX API v2 example PHP code來查找比特幣的當前價格。我摘錄的代碼看起來是這樣的:如何在PHP中顯示數組的特定元素

<?php 
$result = $mtGoxClient->getTicker(); 
?> 

<pre> 
    <?php print_r($result);?> 
</pre> 

我得到以下輸出:

Array 
(
    [result] => success 
    [data] => Array 
     (
      [high] => Array 
       (
        [value] => 1056.90000 
        [value_int] => 105690000 
        [display] => $1,056.90000 
        [display_short] => $1,056.90 
        [currency] => USD 
       ) 

      [low] => Array 
       (
        [value] => 856.12300 
        [value_int] => 85612300 
        [display] => $856.12300 
        [display_short] => $856.12 
        [currency] => USD 
       ) 

      [avg] => Array 
       (
        [value] => 947.15239 
        [value_int] => 94715239 
        [display] => $947.15239 
        [display_short] => $947.15 
        [currency] => USD 
       ) 

      [vwap] => Array 
       (
        [value] => 943.98795 
        [value_int] => 94398795 
        [display] => $943.98795 
        [display_short] => $943.99 
        [currency] => USD 
       ) 

      [vol] => Array 
       (
        [value] => 23521.92105774 
        [value_int] => 2352192105774 
        [display] => 23,521.92105774Â BTC 
        [display_short] => 23,521.92Â BTC 
        [currency] => BTC 
       ) 

      [last_local] => Array 
       (
        [value] => 922.50002 
        [value_int] => 92250002 
        [display] => $922.50002 
        [display_short] => $922.50 
        [currency] => USD 
       ) 

      [last_orig] => Array 
       (
        [value] => 922.50002 
        [value_int] => 92250002 
        [display] => $922.50002 
        [display_short] => $922.50 
        [currency] => USD 
       ) 

      [last_all] => Array 
       (
        [value] => 922.50002 
        [value_int] => 92250002 
        [display] => $922.50002 
        [display_short] => $922.50 
        [currency] => USD 
       ) 

      [last] => Array 
       (
        [value] => 922.50002 
        [value_int] => 92250002 
        [display] => $922.50002 
        [display_short] => $922.50 
        [currency] => USD 
       ) 

      [buy] => Array 
       (
        [value] => 922.00000 
        [value_int] => 92200000 
        [display] => $922.00000 
        [display_short] => $922.00 
        [currency] => USD 
       ) 

      [sell] => Array 
       (
        [value] => 922.50002 
        [value_int] => 92250002 
        [display] => $922.50002 
        [display_short] => $922.50 
        [currency] => USD 
       ) 

      [item] => BTC 
      [now] => 1386808426752872 
     ) 

) 

我會用什麼PHP代碼只得到了[數據] [大] [display_short](一讀數爲$ 1,056.90)?

+1

'$ result ['data'] ['high'] ['display_short']' –

回答

相關問題