Created
August 6, 2012 18:38
-
-
Save joshmh/3277395 to your computer and use it in GitHub Desktop.
Bitcoin Price
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function btc_price($price_in_usd) { | |
$url = 'https://mtgox.com/api/0/data/ticker.php?Currency=usd'; | |
$response = http_parse_message(http_get($url))->body; | |
$obj = json_decode($response, true); | |
$last = $obj['ticker']['last']; | |
return number_format( ($price_in_usd / $last), 2 ) . " BTC"; | |
} | |
echo btc_price(25.50); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment