What PHP function can be used to format numbers with thousands separators and decimal points?

To format numbers with thousands separators and decimal points in PHP, you can use the number_format() function. This function takes a number as its first argument and optional parameters for the number of decimal places, the character used as the decimal point, and the character used as the thousands separator. By using number_format(), you can easily format numbers in a human-readable way.

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