我想将e-06转换为PHP中的数字 我的代码是:
<?php
$hashrate = 5000000000;
$str = file_get_contents('http://alloscomp.com/bitcoin/calculator/json?hashrate='.$hashrate.'');
$data = json_decode($str, true); // decode the JSON into an associative array
$coinperhour = $data['coins_per_hour'];
echo $coinperhour;
?>
运行代码后,显示2.2015778741378E-6。如何将其转换为数字?
我尝试使用echo (int)$coinperhour;
,但代码显示0,如何解决?我想代码显示0.00000220157。谢谢
答案 0 :(得分:2)
$i = 2.2015778741378E-6;
echo $i; // 2.2015778741378E-6
echo number_format ($i,11); // 0.00000220158