PHP中的比特币当前值?

时间:2012-11-23 02:48:52

标签: php bitcoin

我想在HTML文档上有一个“当前比特币价格”。我找到了https://mtgox.com/api/0/data/ticker.php,它返回了这个:

{"ticker":{"high":12.43,"low":11.7,"avg":12.10615987,"vwap":12.098317306,"vol":58453,"last_all":12.34351,"last_local":12.34351,"last":12.34351,"buy":12.3341,"sell":12.34351}}

如何将PHP变量设置为last_all(12.34351)的值?

1 个答案:

答案 0 :(得分:3)

这是一个JSON文档。通过使用json_decode,如果将可选的2nd参数设置为true,则可以在PHP对象或PHP数组中对其进行转换,如文档here中所述。

$content = json_decode($string, true);
echo $content["last_all"];