is there any easy way to covert 1 (as number) to one (as word) ?
numbers as numbers to numbers as words.
easy way to covert 1 (as number) to one (as word)
Moderator: General Moderators
Don't think there's a standard function for that, but you could see if str_replace() or a related function could do something for you.
Here is a start 
Code: Select all
function digsToWords( $num ){
//VALIDATE NUMBER HERE
switch( $num ){
case ( $num < 10 ):
return getNumLessThanTen( $num );
break;
case ( $num < 20 ):
case 11:
return 'eleven';
break;
case 12:
return 'twelve';
break;
case 13:
return 'thirteen';
break;
.
..
...
....
case ( $num < 30 ):
return 'twenty ' . getNumLessThanTen( $num );
break;
.
..
...
....
}
}
function getNumLessThanTen( $num ){
//VALIDATE NUMBER HERE
switch( $num ){
case 1:
return 'one';
break;
case 2:
return 'two';
break;
case 3:
return 'three';
break;
.
..
...
....
}
}- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
http://us2.php.net/manual/en/function.n ... .php#40136 should do the trick.