• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

HOW TO: PHP Capital Letters in every word??

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
nikdonovanau
Asked:
nikdonovanau
  • 2
1 Solution
 
VoteyDiscipleCommented:
$var = 'PLEASE HELP ME';
$var = ucwords(strtolower($var));
0
 
VoteyDiscipleCommented:
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
 
nikdonovanauAuthor Commented:
Perfect - Thanks very much for that

Have a good one :)
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now