note 87133 modified in function.ucfirst by danbrown

From: Date: Thu, 20 Nov 2008 15:43:56 +0000
Subject: note 87133 modified in function.ucfirst by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146770@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 <?php /** * 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 --was-- 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 http://php.net/manual/en/function.ucfirst.php

« previous php.notes (#146770) next »