How can you round a number to 2 decimal places in PHP?

To round a number to 2 decimal places in PHP, you can use the number_format() function. This function formats a number with grouped thousands and a specified number of decimal places. By setting the decimal parameter to 2, you can round the number to 2 decimal places.

$number = 123.456789;
$rounded_number = number_format($number, 2);
echo $rounded_number; // Output: 123.46