note 70593 deleted from function.strtoupper by nlopess

From: Date: Sun, 20 May 2007 13:39:44 +0000
Subject: note 70593 deleted from function.strtoupper by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126720@lists.php.net to get a copy of this message
Note Submitter: my email is trucex and its at gmail ---- There are a lot of lengthy examples on doing proper case. If you just need to have the first letter of the string capitalized and the rest lower case, just do this: <?php $string = strtolower($string); $string = substr_replace($string, strtoupper(substr($string, 0, 1)), 0, 1); ?> If you need to have all the words in a sentence like that, just set it up like this: <?php $words = explode(" ", $string); for($i=0; $i<count($words); $i++) { $string = strtolower($words[$i]); $string = substr_replace($string, strtoupper(substr($string, 0, 1)), 0, 1); $pString .= "$string "; } ?> Obviously, you will have a bit more work ahead of you if you want to do anything fancy, but I didn't need anything fancy and I know there are thousands of applications that don't need anything fancy, so keeping it simple works better. :)

« previous php.notes (#126720) next »