PHP中的一个非常小的指数

时间:2018-10-21 22:24:31

标签: php

我的指数非常小,显示如下:

5.2255534523412e-7

我可以将其显示为:

5.22e-7

1 个答案:

答案 0 :(得分:1)

使用sprintf()格式化输出

https://framework7.io/docs/tabs.html

$a = 5.2255534523412e-7;

// change 2 to be how many decimal places you want. The e treats it as scientific notation.
echo sprintf('%.2e', $a);