lcfirst
(PHP 5 >= 5.3.0, PHP 7)
lcfirst — 文字列の最初の文字を小文字にする
説明
lcfirst
( string
$str
) : string
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!
?>
参考
- ucfirst() - 文字列の最初の文字を大文字にする
- strtolower() - 文字列を小文字にする
- strtoupper() - 文字列を大文字にする
- ucwords() - 文字列の各単語の最初の文字を大文字にする