Liz*_*ard 10
使用该功能ucwords(); 这将完成字符串中的每个单词,使用ucfirst()将只做第一个单词.
echo ucwords('hello my name is jim');
// Hello My Name Is Jim
echo ucfirst('hello my name is jim');
// Hello my name is jim
Run Code Online (Sandbox Code Playgroud)
你需要这个ucfirst功能.
如果该字符是字母,则返回str大写的第一个字符的字符串.
它不会使其他字符小写.为确保只有第一个字母为大写,其余全部为小写,您可以执行以下操作:
ucfirst(strtolower($str))
Run Code Online (Sandbox Code Playgroud)