Forum Moderators: coopster

Message Too Old, No Replies

Returning "Twenty-first" for 21 in PHP

         

DrDoc

9:35 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a PHP function that will return, say, "Twenty-first" for 21, "Two Thousand and Three" for 2003, etc.?

Paul in South Africa

9:51 pm on Apr 10, 2003 (gmt 0)

10+ Year Member



I could be wrong but I don't think so. You can display nd, st, rd or th after the day numeral eg 21st, 22nd etc by using S after the j or d in your date() function.

DrDoc

9:56 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I know about the ordinal suffix through date()... but I'd like to get it spelled out.

If it doesn't exist, I guess I'll have to write my own function that does this...

jatar_k

10:36 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I couldn't find one either. I don't think there is one, yet. ;)

DrDoc

10:57 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Darn it ;)

I was hoping I could avoid making my own thingy :)

mavherick

11:58 pm on Apr 10, 2003 (gmt 0)

10+ Year Member



I remember seeing one on phpclasses.org (GNU - GPL) but I can't seem to access the site right now (way too slow for my taste! and buggy also).

If my memory is good, I think it was under Text processing or something under the name number2word.

Anyway, if I come accross the class somewhere else, I'll let you know.

mavherick

Paul in South Africa

6:15 am on Apr 11, 2003 (gmt 0)

10+ Year Member



Information about the class is at thos.mirrors.phpclasses.org/browse.html/package/754.html

DrDoc

7:49 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you mavherick and Paul. With some tweaking that will be exactly what I was looking for :)

DrDoc

6:28 pm on Apr 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, in case someone else wants it, I posted the tweaked and improved class in this thread [webmasterworld.com] (msg 34).