Capitalize Each First Letter?

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
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Capitalize Each First Letter?

Post by toasty2 »

How can I capitalize each first letter of a word in a string? I think I saw something that would do this, but have forgotten since.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Code: Select all

ucwords()
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You go Ninja, you sour cream hat wearing horned baby tool user you.

Ninja in his new hat :arrow: Image or was it this one :arrow: Image. I can't tell with all that ice cream on his head.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Everah wrote:You go Ninja, you sour cream hat wearing horned baby tool user you.

Ninja in his new hat :arrow: Image or was it this one :arrow: Image. I can't tell with all that ice cream on his head.
:D :lol: That's fantastic.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Thanks dude. I am still laughing at it. I must be tired because I am really laughing at it...

Image Image Image
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

Thanks, cool avatar too :wink:
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

It's helpful, but it only capitalizes the first word. :?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

no, ucfirst() does that...
The Manual wrote:ucwords -- Uppercase the first character of each word in a string
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

I just realized the problem, and I was using the correct function. I have underscores in my string instead of spaces, so it sees it all as one word, but I didn't think about it because I display the string as a link (the underscores just look like the rest of the link). I got it fixed now. Thanks anyway :D
Post Reply