Reputation: 31
I have a very small exponential number and it display like:
5.2255534523412e-7
Can I display it become:
5.22e-7
Upvotes: 1
Views: 76
Reputation: 732
Use sprintf() to format the output
$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);
Upvotes: 1