Uppercase The First Character Of Each Word In A String

 
 
Returns a string with the first character of each word in str capitalized, if that character is alphabetic. The definition of a word is any string of characters that is immediately after a whitespace (These are: space, form-feed, newline, carriage return, horizontal tab, and vertical tab).
 
 
  1. <?php

  2. $foo = 'hello world!';

  3. $foo = ucwords($foo);             // Hello World!

  4. echo $foo."n";

  5.  

  6. $bar = 'HELLO WORLD!';

  7. $bar = ucwords($bar);             // HELLO WORLD!

  8. echo $bar."n";

  9. $bar = ucwords(strtolower($bar)); // Hello World!

  10. echo $bar."n";

  11. ?>
 
Copy to Clipboard      Download code as Text Format
 
  Date entered : 3rd Apr 2008
  Rating : No Rating
  Accessed  :  6687
  Submitted by :  goldeekhan
 
   Add Comment  Printer friendly
   View All Comments  Email to a friend
   Add to my Favourites Download PDF version
   Rating  
 
                 Click each image to add
this page to each site.
 
 
 
Comments Available

    No comment available at the moment.Be the first one to make a comment

 
Related PHP Source Codes
  • Spring
  • Wraps a string to a given number of characters using a string break character
  • Make a string's first character uppercase
  • Strip whitespace (or other characters) from the beginning and end of a string
  • Return part of a string

  • Copyright © 2013 VisualBuilder. All rights reserved

    Warning: Unknown(): write failed: Disk quota exceeded (122) in Unknown on line 0

    Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0