3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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($i = 0; $i < 100; $i++)echo numToOrdinalWord($i) . PHP_EOL;
based on ludic
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
eth First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth Fifteenth Sixteenth Seventeenth Eighteenth Nineteenth Twentieth Twenty-First Twenty-Second Twenty-Third Twenty-Fourth Twenty-Fifth Twenty-Sixth Twenty-Seventh Twenty-Eighth Twenty-Ninth Thirtieth Thirty-First Thirty-Second Thirty-Third Thirty-Fourth Thirty-Fifth Thirty-Sixth Thirty-Seventh Thirty-Eighth Thirty-Ninth Fortieth Forty-First Forty-Second Forty-Third Forty-Fourth Forty-Fifth Forty-Sixth Forty-Seventh Forty-Eighth Forty-Ninth Fiftieth Fifty-First Fifty-Second Fifty-Third Fifty-Fourth Fifty-Fifth Fifty-Sixth Fifty-Seventh Fifty-Eighth Fifty-Ninth Sixtieth Sixty-First Sixty-Second Sixty-Third Sixty-Fourth Sixty-Fifth Sixty-Sixth Sixty-Seventh Sixty-Eighth Sixty-Ninth Seventieth Seventy-First Seventy-Second Seventy-Third Seventy-Fourth Seventy-Fifth Seventy-Sixth Seventy-Seventh Seventy-Eighth Seventy-Ninth Eightieth Eighty-First Eighty-Second Eighty-Third Eighty-Fourth Eighty-Fifth Eighty-Sixth Eighty-Seventh Eighty-Eighth Eighty-Ninth Ninetieth Ninety-First Ninety-Second Ninety-Third Ninety-Fourth Ninety-Fifth Ninety-Sixth Ninety-Seventh Ninety-Eighth Ninety-Ninth
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 ethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 NinthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 TenthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 EleventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 TwelfthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 ThirteenthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 FourteenthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 FifteenthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 SixteenthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 SeventeenthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 EighteenthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 NineteenthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 TwentiethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Twenty-NinthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 ThirtiethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Thirty-NinthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 FortiethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Forty-NinthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 FiftiethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Fifty-NinthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 SixtiethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Sixty-NinthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 SeventiethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Seventy-NinthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 EightiethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Eighty-NinthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 NinetiethPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-FirstPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-SecondPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-ThirdPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-FourthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-FifthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-SixthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-SeventhPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-EighthPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ELvFI on line 22 Ninety-NinthPHP_EOL