What PHP function can be used to format a number with a thousand separator?
To format a number with a thousand separator in PHP, you can use the number_format() function. This function takes the number you want to format as the first parameter and optional parameters for decimal points, decimal separator, and thousand separator. By specifying the thousand separator parameter as a comma, you can easily format a number with thousand separators.
$number = 1000000;
$formatted_number = number_format($number, 0, '.', ',');
echo $formatted_number; // Output: 1,000,000