A slight modification from Northie's post here ( http://us2.php.net/manual/en/function.ucfirst.php#68443), where lcfirst may not exist in your PHP build:
<?php
if(false === function_exists('lcfirst'))
{
/**
* Make a string's first character lowercase
*
* @param string $str
* @return string the resulting string.
*/
function lcfirst( $str ) {
$str[0] = strtolower($str[0]);
return (string)$str;
}
}
/* Tests */
echo var_dump(lcFirst(NULL)).'<br />'; /* string(0) "" */
echo var_dump(lcFirst('')) .'<br />'; /* string(0) "" */
echo var_dump(lcFirst('S')) .'<br />'; /* string(1) "S" */
echo var_dump(lcFirst('É')) .'<br />'; /* string(0) "�" */
echo var_dump(lcFirst('Hello World!!!')); /* string(14) "hello World!!!" */
lcfirst
(No version information available, might be only in CVS)
lcfirst — 文字列の最初の文字を小文字にする
説明
string lcfirst
( string $str
)
str の最初の文字がアルファベットであれば、 それを小文字にします。
「アルファベット」かどうかというのは現在のロケールにより決定されます。 たとえば、デフォルトの "C" ロケールでは、a ウムラウト (ä) は変換されません。
パラメータ
- str
-
入力文字列。
返り値
変換後の文字列を返します。
例
例1 lcfirst() の例
<?php
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>
lcfirst
harmor
05-May-2008 03:43
05-May-2008 03:43
