【问题标题】:How do I print 8 decimals in php [duplicate]如何在php中打印8位小数[重复]
【发布时间】:2017-12-21 16:49:12
【问题描述】:

如果我有一个号码:

$num = 0.00638835;

平均有 100 个条目。我想找到平均值并打印出来。

$avg = $num/100;

我的结果打印为:

echo $avg;

6.38835E-5

如何打印:

 .000004928 //or whatever the number is

【问题讨论】:

标签: php


【解决方案1】:

https://www.w3schools.com/php/func_string_number_format.asp

$num = 0.00638835;
$avg = $num/100;
echo number_format ($avg, 8);

0.00006388

【讨论】:

    【解决方案2】:

    echo number_format($a, 10);
    使用数字格式,您可以选择任意位数的小数

    【讨论】:

      【解决方案3】:

      $num = 0.00638835;

      $avg = $num/100;

      echo number_format($avg, 8);

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-07-24
        • 1970-01-01
        • 1970-01-01
        • 2020-01-12
        • 2018-03-09
        • 1970-01-01
        • 1970-01-01
        • 2019-01-02
        相关资源
        最近更新 更多