Php 如何使第二个字符大写?
我经常使用苹果产品名称Php 如何使第二个字符大写?,php,substring,offset,uppercase,Php,Substring,Offset,Uppercase,我经常使用苹果产品名称 "iphone" "ipad" "imac" 使第二个字符大写的最快方法是什么 "iPhone" "iPad" "iMac" 我试过了 必须替换原始变量中的值: $name[1] = strtoupper($name[1]); 必须替换原始变量中的值: $name[1] = strtoupper($name[1]); 完美答案 $word =
"iphone"
"ipad"
"imac"
使第二个字符大写的最快方法是什么
"iPhone"
"iPad"
"iMac"
我试过了
必须替换原始变量中的值:
$name[1] = strtoupper($name[1]);
必须替换原始变量中的值:
$name[1] = strtoupper($name[1]);
完美答案
$word ='iphone';
$result = str_replace(substr($word,1,1),ucfirst(substr($word,1,1)),$word);
echo $result;
完美答案
$word ='iphone';
$result = str_replace(substr($word,1,1),ucfirst(substr($word,1,1)),$word);
echo $result;
这并不能解释您更改了什么或它是如何工作的。这也不能解释您更改了什么或它是如何工作的。可能的重复