EchoFool Posted May 19, 2009 Share Posted May 19, 2009 Hi there, Just a quick question i been using ucfirst(); but have realised it only capatalises the first letter of the string, but this is flawed for me because the string may have more than one word such as: Joe bloggs < this is what it would show... but i need it to capatalise the first letter of every word because its a name so it would be Joe Bloggs. How do i do it because ucfirst(); doesn't do it Quote Link to comment https://forums.phpfreaks.com/topic/158677-solved-upper-case-more-than-one-word/ Share on other sites More sharing options...
JREAM Posted May 19, 2009 Share Posted May 19, 2009 try ucwords(); alternatively you could do this in css with: .element {text-transform: capitalize;} Quote Link to comment https://forums.phpfreaks.com/topic/158677-solved-upper-case-more-than-one-word/#findComment-836880 Share on other sites More sharing options...
MadTechie Posted May 19, 2009 Share Posted May 19, 2009 you need to use ucwords() ie ucwords(strtolower("joe bloggs")); convert to lower first or JOE BLOGGES will fail Quote Link to comment https://forums.phpfreaks.com/topic/158677-solved-upper-case-more-than-one-word/#findComment-836882 Share on other sites More sharing options...
EchoFool Posted May 19, 2009 Author Share Posted May 19, 2009 Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/158677-solved-upper-case-more-than-one-word/#findComment-836886 Share on other sites More sharing options...
MadTechie Posted May 19, 2009 Share Posted May 19, 2009 alternatively you could do this in css with: .element {text-transform: capitalize;} Nice idea.. I didn't think of that, Quote Link to comment https://forums.phpfreaks.com/topic/158677-solved-upper-case-more-than-one-word/#findComment-836888 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.