PHP - 将百分比添加到比特币值
PHP - Add percentage to bitcoin values
我在 php 中有一个简单的代码,我想在比特币价值上增加 3%:
</PHP
$price = "0.00001000"
$price_format = str_replace(".", "", $price);
echo ($price_format + ($price_format / 100 * 3)); // 1030
?>
Return 我的代码:
1030
我需要 return 是:
0.0001030
有谁知道如何根据价格的房屋数量进行计算?
乘以 3% 时可以使用 number_format
以保持小数位不变。将价格乘以 1.03 (3%) 并指定小数点后 8 位。
<?php
$price = 0.00001000;
$new_price = number_format($price * 1.03, 8);
echo $new_price;
这里是 link 到 number_format
的详细信息:
https://www.php.net/manual/en/function.number-format.php
我在 php 中有一个简单的代码,我想在比特币价值上增加 3%:
</PHP
$price = "0.00001000"
$price_format = str_replace(".", "", $price);
echo ($price_format + ($price_format / 100 * 3)); // 1030
?>
Return 我的代码: 1030
我需要 return 是: 0.0001030
有谁知道如何根据价格的房屋数量进行计算?
乘以 3% 时可以使用 number_format
以保持小数位不变。将价格乘以 1.03 (3%) 并指定小数点后 8 位。
<?php
$price = 0.00001000;
$new_price = number_format($price * 1.03, 8);
echo $new_price;
这里是 link 到 number_format
的详细信息:
https://www.php.net/manual/en/function.number-format.php