Created
January 5, 2015 15:33
-
-
Save Anderson-Juhasc/b3415411c78442728664 to your computer and use it in GitHub Desktop.
Conversão de preço USD para BTC
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Conversão de preço USD para BTC</title> | |
</head> | |
<body> | |
<?php | |
$productValue = number_format(25, 2); | |
$satoshi = 100000000; | |
$tickerBtcAverage = json_decode(file_get_contents("https://api.bitcoinaverage.com/ticker/USD/"), true)[ask]; | |
$oneUSDinSatoshi = ($satoshi / $tickerBtcAverage); | |
$productInSatoshi = ceil($productValue * $oneUSDinSatoshi); | |
$productInBTC = number_format($productInSatoshi / $satoshi, 8); | |
?> | |
<h1>Conversão de preço USD para BTC</h1> | |
<p> | |
<strong>Valor do Produto:</strong> $ <?php echo $productValue; ?> | |
</p> | |
<p> | |
<strong>Cotação:</strong> $ <?php echo $tickerBtcAverage; ?> | |
</p> | |
<p> | |
<strong>$ 1.00 em satoshis:</strong> <?php echo $oneUSDinSatoshi; ?> | |
</p> | |
<p> | |
<strong>Valor do produto em satoshis:</strong> <?php echo $productInSatoshi; ?> | |
</p> | |
<p> | |
<strong>Valor do produto em BTC:</strong> <?php echo $productInBTC; ?> | |
</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment