<?php
function numToOrdinalWord($num)
{
$first_word = array('eth', 'First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth',
'Seventh', 'Eighth', 'Ninth', 'Tenth', 'Eleventh', 'Twelfth', 'Thirteenth',
'Fourteenth', 'Fifteenth', 'Sixteenth', 'Seventeenth', 'Eighteenth',
'Nineteenth', 'Twentieth');
$second_word = array('', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety');
if ($num <= 20) return $first_word[$num];
$first_num = substr($num, -1, 1);
$second_num = substr($num, -2, 1);
return $string = str_replace(
'y-eth',
'ieth',
$second_word[$second_num] . '-' . $first_word[$first_num]
);
}
for(int $i = 0; $i < 100; $i++)echo numToOrdinalWord($i) . PHP_EOL;
- Output for 5.4.0 - 5.4.34
- Parse error: syntax error, unexpected '$i' (T_VARIABLE), expecting ';' in /in/ludic on line 22
Process exited with code 255. - Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected T_VARIABLE, expecting ';' in /in/ludic on line 22
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected T_VARIABLE, expecting ';' in /in/ludic on line 22
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error, expecting `';'' in /in/ludic on line 22
Process exited with code 255.
preferences:
213.48 ms | 1399 KiB | 124 Q