如何在php中转换数字,例如1.905e + 06将为1905000 [英] how to convert a number in php, for example 1.905e+06 will be 1905000
本文介绍了如何在php中转换数字,例如1.905e + 06将为1905000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
PHP-摆脱符号
给出数字 1.905e + 06
,如何使用PHP将其转换为非科学符号?有可以使用的功能吗?例如,文字 1.905e + 06
将变为 1905000
.
Given the number 1.905e+06
, how can I convert it to a non-scientific notation using PHP?
Is there a function I could use? For example, the literal 1.905e+06
would become 1905000
.
推荐答案
$n = 1.905e+06;
echo sprintf('%d', $n)."\r\n";
echo (int)$n."\r\n";
echo (int)((float)$n)."\r\n";
echo sprintf('%f', $n)."\r\n";
echo (float)$n."\r\n";
其中任何一种方法?在此处演示
这篇关于如何在php中转换数字,例如1.905e + 06将为1905000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文