What is the function used to format numbers with commas in PHP?

When working with numbers in PHP, it is common to want to format them with commas for better readability. To achieve this, you can use the number_format() function in PHP. This function allows you to format a number with specified decimal points, thousands separator, and decimal separator.

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