I have written a CSV importer and some of the values are very small, for example, in one of the CSVs I have 0.000024 which is being formatted as "2.40E-05" and when PHP puts that into the database it stores it as 2.4, I found an article that said if you add 1 to it, it changes to a float which is what I did and I got 1.000024, but if I then subtract 1, it goes back to being 2.4E-05, what is the best way in PHP to convert a scientific notation string to an actual float value? I would like to be able to store the value in my database as 0.000024.
2
Answers
I just used number_format($revenue, 6) and it stored as 0.000024.
You should convert to a string otherwise if you keep the float it will keep displaying with scientific notation