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

PHP- capitalize all words in a string

Hello!  I've been sitting here Googling this, but getting frustrated because I can't find the PHP code for what I want to do specifically:

$string = I want to CAPITALIZE all WOrds IN a sTRING

How can I make the above string read:

$string = I Want To Capitalize All Words In A Strong

Thank you in advance!!!
0
mcgeorge40
Asked:
mcgeorge40
  • 2
1 Solution
 
glcumminsCommented:
$string = "I want to CAPITALIZE all WOrds IN a sTRING";

$result = ucwords(strtolower($string));
0
 
mcgeorge40Author Commented:
Thanks.  I actually had that code...  And I realized I had a typo.  Darn!  Thank you for the quick response.
0
 
glcumminsCommented:
With PHP's schizophrenic function-naming conventions, typos are often easy to come by, and difficult to spot. I'm glad it is working for you now!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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