Formatting a float value I am fetching data from MySQL using PHP. I know that most values stored in the database are float. Sometimes, the database outputs values like 3.9999E-5 and sometimes like 0.00104961904762 (14 digits).

How can I truncate the value to 8 digits only. I am currently using:

&lt;? echo sprintf("%.8f",$get_results['Price']);?&gt;
You need MySQL's FORMAT function

To round 0.00000123456 to 8 places, run the following within PHP:

mysql&gt; select FORMAT(0.00000123456,8);
+-------------------------+
| FORMAT(0.00000123456,8) |
+-------------------------+
| 0.00000123              |
+-------------------------+
1 row in set (0.00 sec)

mysql&gt;


Give it a Try !!!