私が必要としているものとは正反対のことをするucwordsと呼ばれる PHP の関数が既にあります。
lcwords という php ライブラリはありますか? すべての単語の最初を大文字にする代わりに、小文字に変換します。
ありがとう。
ここにワンライナーがあります:
implode(' ', array_map(function($e) { return lcfirst($e); }, explode(' ', $words)))
例:
function lcwords($words) {
return implode(' ', array_map(function($e) { return lcfirst($e); }, explode(' ', $words)));
}
$words = "First Second Third";
$lowercased_words = lcwords($words);
echo($lowercased_words);
これはあなたに役立つかもしれません
$str="hello";
$test=substr($str, 0,1);
$test2=substr($str, 1,strlen($str));
echo $test.strtoupper($test2);
さらに短いワンライナー:
implode(' ',array_map('lcfirst',explode(' ',$text)))
Google で「文字列 php の各単語の最初の文字を小文字にする」と、これが最初の応答です: http://php.net/manual/en/function.lcfirst.php