Reputation: 2562
I'm currently playing around with the NumberFormatter
class, but I noticed a strange behaviour.
I'm trying to have two fraction digits, but depending on the PHP version, sometimes the result is correct and sometimes I only have a single fraction digit.
$formatter = new \NumberFormatter("fr_FR", \NumberFormatter::PADDING_POSITION);
$formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 0);
$formatter->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, 2);
echo $formatter->format(12345);
Here is a snippet that illustrate my purpose: https://3v4l.org/9kFeb
The result is 12,34 k
in some versions, 12,3 k
in others.
I'm curious to know what's going on, is it my example that's wrong?
What I've tried:
Upvotes: 2
Views: 59
Reputation: 157915
Judging by version numbers, it looks exactly like a bug that has been fixed, in the versions released on 11 Apr 2024 (8.1.28, 8.2.18, 8.3.5).
Though I cannot find a relevant entry in the release notes. The only rational explanation I can come up with is that some other fix collaterally fixed this one as well.
Or, it could have been fixed in the underlying library and came into effect when PHP dependencies have been updated. Which seems even more plausible because PHP uses Unicode Consortium's ICU library for its Intl extension.
Upvotes: 1