note 109198 deleted from function.ucwords by danbrown
| From: | danbrown@php.net | Date: | Wed, 27 Jun 2012 16:38:22 +0000 |
| Subject: | note 109198 deleted from function.ucwords by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-188942@lists.php.net to get a copy of this message | ||
Note Submitter: Patrice Vanneufville
----
Voici une fonction qui prend en compte les espaces et les tirets :
(Make the first letter of any word in capital even they are separated by hyphen)
<?php
function ucwordspecific($str) {
return preg_replace('/(?<=^|-| )(.?)/e',"strtoupper('$1')", $str);
}
?>
L'exemple : ucwordspecific("mark-yves robert-bryan")
donne : "Mark-Yves Robert-Bryan"