note 63799 added to function.ucfirst

From: Date: Fri, 31 Mar 2006 08:34:22 +0000
Subject: note 63799 added to function.ucfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-107062@lists.php.net to get a copy of this message
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 -- http://www.php.net/manual/en/function.ucfirst.php Edit -- http://master.php.net/note/edit/63799 Del: integrated -- http://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://master.php.net/note/delete/63799/spam Del: non-english -- http://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://master.php.net/manage/user-notes.php

« previous php.notes (#107062) next »