What is the function in PHP to add thousand separators to a number?

When working with numbers in PHP, you may need to add thousand separators to improve readability. One way to achieve this is by using the number_format() function in PHP. This function allows you to format a number with grouped thousands. Simply pass the number you want to format as the first parameter, and specify the number of decimal places, thousands separator, and decimal point as optional parameters.

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