Solved

HOW TO: PHP Capital Letters in every word??

Posted on 2006-11-05
3
315 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
ID: 17878875
$var = 'PLEASE HELP ME';
$var = ucwords(strtolower($var));
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17878878
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
ID: 17878892
Perfect - Thanks very much for that

Have a good one :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use md5 hashing 3 27
Amazon Redshift 2 26
phpmailer in WHILE loop - weird results 10 27
How can I echo a PHP variable in AJAX function? 7 32
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

910 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

24 Experts available now in Live!

Get 1:1 Help Now