Solved

HOW TO: PHP Capital Letters in every word??

Posted on 2006-11-05
3
314 Views
Last Modified: 2012-05-05
Hi Experts

I have a string I want to convert every word in the string to capital starting letter.

Eg
From
'PLEASE HELP ME' or 'please help me'
to
'Please Help Me'

Thanks for your help

Cheers
Nik
0
Comment
Question by:nikdonovanau
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 500 total points
Comment Utility
$var = 'PLEASE HELP ME';
$var = ucwords(strtolower($var));
0
 
LVL 19

Expert Comment

by:VoteyDisciple
Comment Utility
The classic mistake is to write just ucwords($var) but that's incorrect.  ucwords() will only make the beginning letter of each word uppercase; it will not make anything else lowercase.  That's easy to work around, though: just convert the entire string to lowercase first, THEN convert all the beginnings of words to uppercase.
0
 
LVL 1

Author Comment

by:nikdonovanau
Comment Utility
Perfect - Thanks very much for that

Have a good one :)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now