简体   繁体   中英

Remove useless zero from scientific notation in PHP

Is there any way to Remove useless zero from scientific notation and make the number as simple as possible.

In PHP I have the following code:

<?PHP
  $result = 1/1000000000;
  echo $result;
?>

the output is 1.0E-9

it should 1E-9

If you need it this way you can use str_replace :

$result = 1/1000000000;
echo str_replace(".0E", "E", $result);

This outputs 1E-9

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM