Register   Login       Forum   Search   Help  

Post new topic Reply to topic
The Web Hosting Forum > Programming & Technical > PHP String Proper

Author Thread
Thermit
Site Admin


Joined: 11 Aug 2004
Posts: 272
PHP String Proper  Reply with quote  

I noticed PHP provides toupper and tolower type string manipulation functions, but what if you wanted to take...

>> some text to look nice ASAP

and make it look like this...

>> Some Text To Look Nice ASAP

I know this is just a simple loop, but wondering if anyone has seen an existing routine or function to do this?


Post Tue Mar 15, 2005 4:43 am
 View user's profile Send private message
Euler



Joined: 02 Sep 2004
Posts: 109
ucwords  Reply with quote  

That would be ucwords()

From the manual:
code:

<?php
$foo = 'hello world!';
$foo = ucwords($foo);            // Hello World!

$bar = 'HELLO WORLD!';
$bar = ucwords($bar);            // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>




Post Tue Mar 15, 2005 4:56 pm
 View user's profile Send private message
Thermit
Site Admin


Joined: 11 Aug 2004
Posts: 272
 Reply with quote  

Cool!

So, if I don't use the strtolower, it will leave the existing capitalized letters of acronyms alone?

Look like it will, thanks man!


Post Tue Mar 15, 2005 5:10 pm
 View user's profile Send private message
webshome



Joined: 07 Jul 2005
Posts: 6
 Reply with quote  

good function in php

change the upper case or change in lower case the text, can it provde the full text or change the first char

webshome


Post Thu Jul 07, 2005 1:36 pm
 View user's profile Send private message

Post new topic Reply to topic
Forum Jump:
Jump to:  

All times are GMT.
The time now is Wed Feb 08, 2012 9:07 pm
  Display posts from previous: