当前位置:Gxlcms > PHP教程 > 溢出-如何得到PHP浮点型的真实值?1.5265646464633E+21

溢出-如何得到PHP浮点型的真实值?1.5265646464633E+21

时间:2021-07-01 10:21:17 帮助过:4人阅读

PHP每次导出为csv,数字结尾就会变成E+一个数字。

  1. <code><br>$s = 1526564646463333565222;
  2. echo $s;
  3. //1.5265646464633E+21
  4. </code>

PHP如何才可以将浮点型的字符串反转换为 原始值?

  1. <code>function getTrueValue($str){
  2. //@todo
  3. }
  4. $str = '1.5265646464633E+21';
  5. </code>

回复内容:

PHP每次导出为csv,数字结尾就会变成E+一个数字。

  1. <code><br>$s = 1526564646463333565222;
  2. echo $s;
  3. //1.5265646464633E+21
  4. </code>

PHP如何才可以将浮点型的字符串反转换为 原始值?

  1. <code>function getTrueValue($str){
  2. //@todo
  3. }
  4. $str = '1.5265646464633E+21';
  5. </code>

sprintf或者number_format

  1. <code>$s = 1526564646463333565222;
  2. printf("%.0f", $s);
  3. echo "\r\n";
  4. echo number_format($s,0,'','');
  5. </code>

人气教程排行