使用PHP curl从区块链中提取数据

时间:2016-04-24 01:40:13

标签: php curl preg-match

我试图使用cURL从区块链中获取比特币钱包的总美元价值。这是我的代码:

$content2 = file_get_contents("https://blockchain.info/address/1HoB5A1HBbnB3b5gQZ6U78JzA7Hqk9WWYx?currency=USD");

preg_match('#<span data-c="([0-9\.]*)">$ ([0-9\.]*)</span>#Uis', $content2, $USDmatch);

$usd = $USDmatch[0];

echo "Total USD: $usd";

1 个答案:

答案 0 :(得分:0)

您需要使用反斜杠来逃避美元符号。

preg_match('#<span data-c="([0-9\.]*)">\$ ([0-9\.]*)</span>#Uis', $content2, $USDmatch);