note 48206 deleted from function.strtoupper by nlopess
| From: | nlopess@php.net | Date: | Thu, 10 Feb 2005 10:55:53 +0000 |
| Subject: | note 48206 deleted from function.strtoupper by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-84783@lists.php.net to get a copy of this message | ||
Note Submitter: janklopper.at.gmail.dot.com
----
This function takes a string, trim's it, and then changes all the first letters of each
"word" it finds to uppercase.
I use it to clean up all words in name/place/addres fields.
<?php
function capitalize($input){
$output=strtolower(trim($input));
$output=strtoupper($output[0]).substr($output,1);
$i=0;
while($pos=strpos($output,' ',$i)){
$pos++;
$end=($pos+1);
$output=substr($output,0,$pos).
strtoupper($output[$pos]).
substr($output,$end);
$i=$pos;
}
return $output;
}
?>