How to convert bitcoin to real?

Asked

Viewed 325 times

0

Guys, I have the following code that converts for example 14,000 in real to BTC that would give 1.07481682, only that I also wanted to do this guy’s reverse way, turn the 1.07481682 in BTC to 14,000 real. How could I do that?

$url = "https://bitpay.com/api/rates";
$json = file_get_contents($url);
$data = json_decode($json, TRUE);

$bitcoin_price = $data[30]["rate"];
$brl_value = 14000;
$value_bitcoin = round($brl_value / $bitcoin_price, 8);

echo '<pre>';
var_dump($value_bitcoin);
echo '</pre>';
die();

1 answer

4


You have to know the bitcoin quotation, I believe it is the variable $bitcoin_price and multiply by the amount of Coins.

$total = $bitcoin_price * $amount_bitcoin
  • Man, thank you so much, you literally saved my life hahaha

Browser other questions tagged

You are not signed in. Login or sign up in order to post.