[英]Does anyone know how to convert an ordinal to a cardinal number in PHP?
I know there is a way to make a cardinal numeral into an ordinal. 我知道有一种方法可以将基数变成序数。 I can use NumberFormmatter::format for this.
我可以为此使用NumberFormmatter :: format 。 However, I would like to go the other direction.
但是,我想朝另一个方向发展。
The current, (not very good solution in my opinion) is to do the following 当前(我认为不是很好的解决方案)是要执行以下操作
function convertOrdinalToCardinal($word) {
$ordinals = array();
for ($i=1; $i<=100; $i++) {
$ordinals[NumberFormatter::format($i, NumberFormatter::ORDINAL)] = $i;
}
return $ordinals[$word];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.