How can multiplying and dividing by 100 be used to achieve rounding to two decimal places in PHP?

When rounding to two decimal places in PHP, you can multiply the number by 100, round it using the round() function, and then divide it by 100 to get the desired result. This method works because multiplying by 100 moves the decimal point two places to the right, allowing you to round to the nearest integer, and then dividing by 100 moves the decimal point back to its original position.

$number = 123.456;
$rounded_number = round($number * 100) / 100;
echo $rounded_number; // Output: 123.46