Often, we need to format numbers to two decimal places, and PHP has in-built functions to format number to two decimal places using PHP in-built functions.
Format number to two decimal places using ROUND() functions
round() function converts float value to integer value and you can also convert integer value to float value and by passing second parameter you can format number to decimal places.
$number = 100.12345; $number = round($number, 2); echo $number;
Format number to two decimal places using number_format() functions
number_format() function formats a number to decimal points and it accepts two parameters first parameter is the number that you want format and second parameter is the number of places you want to format.
$number = 100.12345; $number = number_format($number, 2); echo $number;