In proper English the numbers zero through nine must be spelled out while ten and above do not. Is there a native function for this in PHP?
In example...
Zero
One
Two
Three
Four
Five
Six
Seven
Eight
Nine
10
11
12
etc...
PHP function to spell out numbers 1-9 for proper English?
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: PHP function to spell out numbers 1-9 for proper English?
Debatable.JAB Creations wrote:In proper English the numbers zero through nine must be spelled out while ten and above do not.
Not that I know of.JAB Creations wrote:Is there a native function for this in PHP?
Code: Select all
function spell($number) {
if ($number >= 0 && $number < 10 && (is_int($number) || ctype_digit($number))) {
$numbers = array("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine");
return $numbers[$number];
} else return $number;
}- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: PHP function to spell out numbers 1-9 for proper English?
I'm not interested in debating English grammar. 
That was a quick reply, did you write that function out that quickly or was it something you've had archived? I appreciate it, thanks!
That was a quick reply, did you write that function out that quickly or was it something you've had archived? I appreciate it, thanks!
Re: PHP function to spell out numbers 1-9 for proper English?
Just wrote it. Simple enough, only took a minute.JAB Creations wrote:That was a quick reply, did you write that function out that quickly or was it something you've had archived?