note 87133 added to function.ucfirst
| From: | svetoslavm at gmail dot com | Date: | Thu, 20 Nov 2008 15:40:29 +0000 |
| Subject: | note 87133 added to function.ucfirst | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146769@lists.php.net to get a copy of this message | ||
For some reason this worked for me.
Mac OS 10.5.1
PHP 5.2.6
/**
* ucfirst UTF-8 aware function
*
* @param string $string
* @return string
* @see http://ca.php.net/ucfirst
*/
function my_ucfirst($string, $e ='utf-8') {
if (function_exists('mb_strtoupper') &&
function_exists('mb_substr') && !empty($string)) {
$string = mb_strtolower($string, $e);
$upper = mb_strtoupper($string, $e);
preg_match('#(.)#us', $upper, $matches);
$string = $matches[1] . mb_substr($string, 1, mb_strlen($string, $e), $e);
} else {
$string = ucfirst($string);
}
return $string;
}
Svetoslav Marinov
http://slavi.biz
----
Server IP: 66.207.199.35
Probable Submitter: 216.221.92.71
----
Manual Page -- http://www.php.net/manual/en/function.ucfirst.php
Edit -- https://master.php.net/note/edit/87133
Del: integrated -- https://master.php.net/note/delete/87133/integrated
Del: useless -- https://master.php.net/note/delete/87133/useless
Del: bad code -- https://master.php.net/note/delete/87133/bad+code
Del: spam -- https://master.php.net/note/delete/87133/spam
Del: non-english -- https://master.php.net/note/delete/87133/non-english
Del: in docs -- https://master.php.net/note/delete/87133/in+docs
Del: other reasons-- https://master.php.net/note/delete/87133
Reject -- https://master.php.net/note/reject/87133
Search -- https://master.php.net/manage/user-notes.php