note 107701 added to function.ucwords
| From: | qeremy | Date: | Mon, 27 Feb 2012 17:09:07 +0000 |
| Subject: | note 107701 added to function.ucwords | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186401@lists.php.net to get a copy of this message | ||
A proper Turkish solution;
<?php
function ucfirst_turkish($str) {
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
return mb_convert_case(
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
$tmp[1];
}
// function ucwords_turkish($str) {
// return join(" ", array_map(
// "ucfirst_turkish", preg_split("/\s/u", $str)));
// }
function ucwords_turkish($str) {
return preg_replace("/(\w+)/ue",
"ucfirst_turkish('\\1').'$2'", $str);
}
$str = "iyilik güzelLİK Åeker ";
echo ucwords($str) ."\n"; // Iyilik GüzelLİK Åeker
echo ucwords_turkish($str); // İyilik GüzelLİK Åeker
?>
----
Server IP: 69.147.83.197
Probable Submitter: 194.27.149.90
----
Manual Page -- http://www.php.net/manual/en/function.ucwords.php
Edit -- https://master.php.net/note/edit/107701
Del: integrated -- https://master.php.net/note/delete/107701/integrated
Del: useless -- https://master.php.net/note/delete/107701/useless
Del: bad code -- https://master.php.net/note/delete/107701/bad+code
Del: spam -- https://master.php.net/note/delete/107701/spam
Del: non-english -- https://master.php.net/note/delete/107701/non-english
Del: in docs -- https://master.php.net/note/delete/107701/in+docs
Del: other reasons-- https://master.php.net/note/delete/107701
Reject -- https://master.php.net/note/reject/107701
Search -- https://master.php.net/manage/user-notes.php