What function can be used to format numbers in PHP?

To format numbers in PHP, you can use the number_format() function. This function allows you to format a number with grouped thousands and decimal points. You can specify the number of decimal places, the decimal separator, and the thousands separator. This is useful for displaying numbers in a more readable format, such as adding commas to large numbers.

$number = 1234567.89;
$formatted_number = number_format($number, 2, '.', ',');
echo $formatted_number; // Output: 1,234,567.89