How can the number_format() function be used to format large numbers in PHP?

When dealing with large numbers in PHP, the number_format() function can be used to format the number by adding commas as thousands separators. This makes the number more readable and easier to understand. The function takes the number as its first parameter and optional parameters for decimal points and decimal separators.

$largeNumber = 1000000;
$formattedNumber = number_format($largeNumber);
echo $formattedNumber; // Output: 1,000,000