note 73363 deleted from function.strtoupper by philip
| From: | philip@php.net | Date: | Tue, 20 Feb 2007 07:32:39 +0000 |
| Subject: | note 73363 deleted from function.strtoupper by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123590@lists.php.net to get a copy of this message | ||
Note Submitter: lskatz at gmail dot com
Reason: bad code
----
So far my function to capitalize all the words in a string has been good. It will convert any
whitespace to a space though.
function capitalize($word){
$output='';
$word=preg_split('/\s+/',$word);
for($i=0;$i<count($word);$i++){
$char=substr($word[$i],0,1);
$char=strtoupper($char);
$output.=$char . substr($word[$i],1);
if($word[$i+1]) $output.=' ';
}
return $output;
}