List Info

Thread: note 63799 added to function.ucfirst




note 63799 added to function.ucfirst
user name
2006-03-31 08:34:22
A combination of the below functions to enable ucfirst for
multibyte strings in a shared hosting environment (where you
can not always count on mbstring to be installed):

<?php
function my_mb_ucfirst($str, $e='utf-8') {
    if (function_exists('mb_strtoupper')) {
        $fc = mb_strtoupper(mb_substr($str, 0, 1, $e), $e); 
        return $fc.mb_substr($str, 1, mb_strlen($str, $e),
$e);
    }
    else { 
        $str = utf8_decode($str);
        $str[0] = strtr($str[0],
            "abcdefghýijklmnopqrstuvwxyz".
            "\x9C\x9A\xE0\xE1\xE2\xE3".
            "\xE4\xE5\xE6\xE7\xE8\xE9".
            "\xEA\xEB\xEC\xED\xEE\xEF".
            "\xF0\xF1\xF2\xF3\xF4\xF5".
            "\xF6\xF8\xF9\xFA\xFB\xFC".
            "\xFE\xFF",
            "ABCDEFGHÝIJKLMNOPQRSTUVWXYZ".
           
"\x8C\x8A\xC0\xC1\xC2\xC3\xC4".
           
"\xC5\xC6\xC7\xC8\xC9\xCA\xCB".
           
"\xCC\xCD\xCE\xCF\xD0\xD1\xD2".
           
"\xD3\xD4\xD5\xD6\xD8\xD9\xDA".
            "\xDB\xDC\xDE\x9F");
        return utf8_encode($str);
    }
}
?>
----
Server IP: 194.153.94.11
Probable Submitter: 213.180.171.13
----
X-Spam-Status: No, hits=3.8 required=5.0
tests=DATE_MISSING,FROM_NO_LOWER,
	UPPERCASE_25_50 autolearn=no version=2.64
----
Manual Page -- htt
p://www.php.net/manual/en/function.ucfirst.php
Edit        -- http://master.p
hp.net/note/edit/63799
Del: integrated  -- ht
tp://master.php.net/note/delete/63799/integrated
Del: useless     -- http:
//master.php.net/note/delete/63799/useless
Del: bad code    -- http
://master.php.net/note/delete/63799/bad+code
Del: spam        -- http://m
aster.php.net/note/delete/63799/spam
Del: non-english -- h
ttp://master.php.net/note/delete/63799/non-english
Del: in docs     -- http:
//master.php.net/note/delete/63799/in+docs
Del: other reasons-- http://master
.php.net/note/delete/63799
Reject      -- http://master
.php.net/note/reject/63799
Search      -- http://ma
ster.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )