Capitalize text function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
josamoto
Forum Commoner
Posts: 41
Joined: Fri Aug 24, 2007 6:57 am
Location: South Africa
Contact:

Capitalize text function

Post by josamoto »

I'm looking for a function to capitalize text, so for example if someone has entered a string in ALL CAPS, I want the PHP function to convert it to proper written English syntax, i.e. Sentences start with a capital letter etc.

Any suggestions?
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

http://www.php.net/manual/en/ref.strings.php read that page. Should be plenty of useful functions.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

strtoupper should do what you need.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

CoderGoblin wrote:strtoupper should do what you need.
I believe ~josamoto is looking to make sure it's not in all caps. ;)

ucwords() and ucfirst() may be of interest, however they will not handle proper names well.
User avatar
josamoto
Forum Commoner
Posts: 41
Joined: Fri Aug 24, 2007 6:57 am
Location: South Africa
Contact:

Post by josamoto »

Thanks guys! Your replies have been most useful! Much appreciated. :)
Post Reply