convert double to string in php with 2 decimal places code example Example: fix to 2 decimal places php return number_format((float)$number, 2, '.', '');