Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 1753

[3.3.x] Translations • Re: How do I get "%2$.2f seconds" to show "1,23" instead of "1.23"

$
0
0
You can use the NumberFormatter class in PHP to format numbers with commas. Here’s a quick example of how to do it:
$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



Viewing all articles
Browse latest Browse all 1753

Trending Articles