Re: strtolower -> strtoupper
| From: | Michael Sims | Date: | Thu, 12 Sep 2002 03:04:54 +0000 |
| Subject: | Re: strtolower -> strtoupper | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116068@lists.php.net to get a copy of this message | ||
On Thu, 12 Sep 2002 05:21:01 +0300, you wrote:
[...]
>$name = "mattson-hedman" # correct format is Mattson-Hedman, but user
>can write in many ways. $name came from db.
>
>so how I can convert this $name format "Mattson-Hedman".
[...]
Try this:
function uc_all ($str) {
$temp = preg_split('/(\W)/', $str, -1,PREG_SPLIT_DELIM_CAPTURE);
foreach ($temp as $key => $word) {
$temp[$key] = ucfirst(strtolower($word));
}
return join ('', $temp);
}