Forum Moderators: coopster

Message Too Old, No Replies

ucwords question

         

weddingm

6:31 pm on Nov 3, 2009 (gmt 0)

10+ Year Member



I am using ucwords to capitalize the words submitted in an input form. The issue is when they use all caps. Is there a code to use that will capitalize the first letter and lower case the rest?

Tommybs

6:40 pm on Nov 3, 2009 (gmt 0)

10+ Year Member



ucwords(strtolower($input));
should do the trick. Though I don't know if you still need this having seen my other reply. This will capitalize the first letter of every word though.

If you still need this just for the first word though I guess you could use something like:


ucwords(strtolower(substr($input,0,strpos($input," "))));

There might be a neater way of doing this but that should get you started

TheMadScientist

3:12 am on Nov 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There might be a neater way of doing this but that should get you started

$input=ucfirst(strtolower($input));