如何使第二个字符大写?
How to make the second character uppercase?
我经常使用 Apple Product Name
"iphone"
"ipad"
"imac"
将第二个字符变为大写的最快方法是什么?
"iPhone"
"iPad"
"iMac"
我试过了
// $name = iphone
if ($name[0] == 'i') {
strtoupper($name[1]);
dd($name); //iphone
}
您必须替换原始变量中的值:
$name[1] = strtoupper($name[1]);
完美答案
$word ='iphone';
$result = str_replace(substr($word,1,1),ucfirst(substr($word,1,1)),$word);
echo $result;
我经常使用 Apple Product Name
"iphone"
"ipad"
"imac"
将第二个字符变为大写的最快方法是什么?
"iPhone"
"iPad"
"iMac"
我试过了
// $name = iphone
if ($name[0] == 'i') {
strtoupper($name[1]);
dd($name); //iphone
}
您必须替换原始变量中的值:
$name[1] = strtoupper($name[1]);
完美答案
$word ='iphone';
$result = str_replace(substr($word,1,1),ucfirst(substr($word,1,1)),$word);
echo $result;