3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function ordinal($cdnl){ $test_c = abs($cdnl) % 10; $ext = ((abs($cdnl) %100 < 21 && abs($cdnl) %100 > 4) ? 'th' : (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1) ? 'th' : 'st' : 'nd' : 'rd' : 'th')); return $cdnl.$ext; } for($i=1;$i<100;$i++){ echo ordinal($i).'<br>'; } ?>
Output for 4.3.0 - 7.1.0
1st<br>2nd<br>3rd<br>4th<br>5th<br>6th<br>7th<br>8th<br>9th<br>10th<br>11th<br>12th<br>13th<br>14th<br>15th<br>16th<br>17th<br>18th<br>19th<br>20th<br>21st<br>22nd<br>23rd<br>24th<br>25th<br>26th<br>27th<br>28th<br>29th<br>30th<br>31st<br>32nd<br>33rd<br>34th<br>35th<br>36th<br>37th<br>38th<br>39th<br>40th<br>41st<br>42nd<br>43rd<br>44th<br>45th<br>46th<br>47th<br>48th<br>49th<br>50th<br>51st<br>52nd<br>53rd<br>54th<br>55th<br>56th<br>57th<br>58th<br>59th<br>60th<br>61st<br>62nd<br>63rd<br>64th<br>65th<br>66th<br>67th<br>68th<br>69th<br>70th<br>71st<br>72nd<br>73rd<br>74th<br>75th<br>76th<br>77th<br>78th<br>79th<br>80th<br>81st<br>82nd<br>83rd<br>84th<br>85th<br>86th<br>87th<br>88th<br>89th<br>90th<br>91st<br>92nd<br>93rd<br>94th<br>95th<br>96th<br>97th<br>98th<br>99th<br>