PHP字符串分割,首字母大写
作者:
凌乱秋天 | 来源:发表于
2017-07-28 22:18 被阅读0次/**
* 写一个方法可以实现如下功能;
server_name转为 serverName
user_name 转为 userName
pass_word_id 转为 passWordId
*/
function getStr($str){
if(empty($str)) return false;
$arr = explode('_',$str);
$newArr = [];
foreach($arr as $key => $value){
if($key > 0){
$newArr[] = ucfirst($value);
}else{
$newArr[] = $value;
}
}
$newStr = implode('',$newArr);
return $newStr;
}
$str = "array_chunk_ee";
$string = getStr($str);
print_r($string);
本文标题:PHP字符串分割,首字母大写
本文链接:https://www.haomeiwen.com/subject/jjzflxtx.html
网友评论