Posted By

iloveitaly on 08/24/10


Tagged

titlecase


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

roli000


ucname / Title Case


 / Published in: PHP
 

URL: http://php.net/manual/en/function.ucwords.php

Grabbed it from the comments for ucfirst

  1. function ucname($string) {
  2. $string = ucwords(strtolower($string));
  3.  
  4. foreach(array('-', '\'') as $delimiter) {
  5. if (strpos($string, $delimiter) !== false) {
  6. $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
  7. }
  8. }
  9.  
  10. return $string;
  11. }

Report this snippet  

You need to login to post a comment.