How to convert bitcoin to real?

0

I have the following code that converts, for example, 14,000 into BTCs that would give 1.07481682 , but I also wanted to do the reverse path for this guy, transform the 1.07481682 in BTC for 14,000 real. How could I do this?

$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();
    
asked by anonymous 16.08.2017 / 04:14

1 answer

4

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

$total = $bitcoin_price * $amount_bitcoin
    
16.08.2017 / 04:19