You can use the NumberFormatter class in PHP to format numbers with commas. Here’s a quick example of how to do it:
This will format 1.23 as 1,23. Just replace en_US with your locale if needed.
$formatter = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
$formatter->setSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, ',');
$number = 1.23;
$formattedNumber = $formatter->format($number);
echo sprintf('Installed Data: %1$s; Time: %s seconds', 'Data', $formattedNumber);
This will format 1.23 as 1,23. Just replace en_US with your locale if needed.
Statistics: Posted by Terceirense — Thu Aug 22, 2024 5:57 pm