note 20949 added to function.strtoupper

From: Date: Tue, 23 Apr 2002 04:53:59 +0000
Subject: note 20949 added to function.strtoupper
Groups: php.notes 
Request: Send a blank email to php-notes+get-29714@lists.php.net to get a copy of this message
Here is a nice function I wrote to convert a string into title case. i.e. from => "the grapes of wrath" to => "The Grapes Of Wrath" Here is my function: ========================================== function strtotitle($strtochange){ $strtochange = strtolower($strtochange); $string_array = explode(" ",$strtochange); $fixed_str = ""; foreach ($string_array as $part){ $fixed_str .= strtoupper(substr("$part",0,1)); $fixed_str .= substr("$part",1,strlen($part)); $fixed_str .= " "; } return rtrim($fixed_str); } $title_str = strtotitle($STRING_TO_CHANGE); ========================================== I hope this helps someone... I know it worked out perfect for me! Enjoy! -- http://www.php.net/manual/en/function.strtoupper.php http://master.php.net/manage/user-notes.php?action=edit+20949 http://master.php.net/manage/user-notes.php?action=delete+20949 http://master.php.net/manage/user-notes.php?action=reject+20949

« previous php.notes (#29714) next »