0

I am trying to grab the total USD value of a bitcoin wallet from blockchain using cURL. Here is my code:

$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
    Possible duplicate of [How do you parse and process HTML/XML in PHP?](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – user3942918 Apr 24 '16 at 01:42

1 Answers1

0

You need to use backslash to escape the dollar sign.

preg_match('#<span data-c="([0-9\.]*)">\$ ([0-9\.]*)</span>#Uis', $content2, $USDmatch);
Petr Hejda
  • 27,988
  • 6
  • 48
  • 69