-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tino Ehrich
committed
Mar 31, 2015
1 parent
f11e145
commit 9d580ef
Showing
1 changed file
with
15 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,10 +36,21 @@ | |
"ordinal" => function ($number) | ||
{ | ||
$b = $number % 10; | ||
$output = (~~($number % 100 / 10) === 1) ? 'th' : | ||
($b === 1) ? 'st' : | ||
($b === 2) ? 'nd' : | ||
($b === 3) ? 'rd' : 'th'; | ||
|
||
switch ($b) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fightbulc
Owner
|
||
{ | ||
case 1: | ||
$output = 'st'; | ||
break; | ||
case 2: | ||
$output = 'nd'; | ||
break; | ||
case 3: | ||
$output = 'rd'; | ||
break; | ||
default: | ||
$output = 'th'; | ||
} | ||
|
||
return $number . "[$output]"; | ||
}, | ||
|
Is this working for values between 10 and 19? Doesn't seem to me from reading the code, but maybe I'm missing something.
What worked for me (I have an older version) was to modify the old code to include some brackets: