How can PHP be used to display decimal numbers with commas?

When displaying decimal numbers with commas in PHP, you can use the number_format() function. This function allows you to format a number with grouped thousands and a specified number of decimal points. By using number_format(), you can easily display decimal numbers with commas in PHP.

$number = 12345.67;
$formatted_number = number_format($number, 2, '.', ',');
echo $formatted_number; // Outputs: 12,345.67