对于 ($rank=0; $rank<100; $rank++) { printf("你的排名: %d%s", $rank, $suffix);
是否存在gettext函数将$suffix本地化为当前语言并返回,例如:
Your rank: 0th
Your rank: 1st
Your rank: 2nd
Your rank: 3rd
Your rank: 4th
如果当前语言环境是英语,并且当语言环境设置为其他语言时数字的正确“序数”形式是什么?
谢谢。
最佳答案
据我所知,您可以使用 NumberFormatter
$nf = new NumberFormatter('en_US', NumberFormatter::ORDINAL);
print $nf->format(123); // prints 123rd
来源:
关于php - 本地化序数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2453594/