What PHP function can be used to properly format large numbers with a comma or period separator?

When dealing with large numbers in PHP, it is common to want to format them with a comma or period separator to improve readability. One way to achieve this is by using the number_format() function in PHP. This function allows you to specify the number you want to format and the number of decimal places, as well as the thousands separator and decimal point characters.

$number = 1000000;
$formatted_number = number_format($number);
echo $formatted_number; // Output: 1,000,000