Convert exponentials to number in PHP

Convert exponentials to number in PHP

Some time it is required to convert exponentials to number. This is required mainly when we read data from CSV or Excel files. CSV and Excel files convert large numbers in to Exponential form and when we read the data through PHP code (fgetcsv() for CSV files) we get the value in Exponential form like 1.256E+12.

We have a built in function in PHP to convert the exponentails to number.

Function : number_format()
Syntax : number_format ( float $number , int $decimals = 0 , string $dec_point = ‘.’ , string $thousands_sep = ‘,’ )
Example to convert 6.90743E+11 to number use below code

number_format(6.90743E+11,0,'','') // outputs 690743000000

 

Leave a Reply

Your email address will not be published. Required fields are marked *