大驼峰转点链接
作者:
笺戈浅 | 来源:发表于
2018-11-17 10:19 被阅读0次$path ="IndexController@inex";
$current = '';//定义一个空字符串
//循环目标字符串
for ($i = 0; $i < strlen($path); $i++) {
$s = $path{$i};//获取当前一个字符
//转指定非标准大写字符
if ($s == '@') {
$current .= ".";
} else {
//计算ASCII值,来判断是否是大写并且是大驼峰首字符
if (ord($s) > 64 && ord($s) < 91 && $i == 0) {
$current .= strtolower($s);//是大写,转成小写,前面追加符号
} else {
//计算ASCII值,来判断是否是大写
if (ord($s) > 64 && ord($s) < 91) {
$current .= ".".strtolower($s);
} else {
$current .= $s;
}
}
}
}
echo PHP_EOL,$current,PHP_EOL;
本文标题:大驼峰转点链接
本文链接:https://www.haomeiwen.com/subject/etsbfqtx.html
网友评论