note 101152 deleted from function.ucwords by danbrown

From: Date: Tue, 30 Nov 2010 15:07:19 +0000
Subject: note 101152 deleted from function.ucwords by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174476@lists.php.net to get a copy of this message
Note Submitter: webenformasyon at gmail dot com ---- for utf-8 encoding we can create a mb_ucwords function like this . for turkish i have an exception with "i" because in english its uppercase is "I" but i need "İ" so i chose to change it manually. mb_internal_encoding("UTF-8"); mb_regex_encoding("UTF-8"); function mb_ucwords($str) { $str = mb_strtolower(trim($str)); $words = explode(" ", $str);$wordsUpper=array(); for($i=0;$i<count($words);$i++){ $firstLetter=mb_substr($words[$i],0,1); if($firstLetter=="i") $firstLetter="İ"; $wordsUpper[$i]=mb_strtoupper($firstLetter) . mb_substr($words[$i],1); } return implode(" ",$wordsUpper); }

« previous php.notes (#174476) next »