php如何将数字转换成科学计数法

如何将0.00001转换成1.00E-05 ?

最佳答案

php 自带函数
参考官方文档 sprintf

e
The argument is treated as scientific notation (e.g. 1.2e+2). The precision specifier stands for the number of digits after the decimal point since PHP 5.2.1. In earlier versions, it was taken as number of significant digits (one less).

E
Like the e specifier but uses uppercase letter (e.g. 1.2E+2).