Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道有一种方法可以将基数词变成序数词。我可以为此使用NumberFormmatter::format。但是,我想去另一个方向。
当前,(我认为不是很好的解决方案)是执行以下操作
function convertOrdinalToCardinal($word) { $ordinals = array(); for ($i=1; $i<=100; $i++) { $ordinals[NumberFormatter::format($i, NumberFormatter::ORDINAL)] = $i; } return $ordinals[$word]; }