复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27/** * @purpose 下划线转小驼峰 * @author ffx * @param string $str 字符串 * @return null|string|string[] */ function lineToHump($str) { $str = preg_replace_callback('/([-_]+([a-z]{1}))/i',function($matches){ return strtoupper($matches[2]); },$str); return $str; } /** * @purpose 驼峰转下划线 * @author ffx * @param $str * @return string */ function humpToLine($str) { $str = str_replace("_", "", $str); $str = preg_replace_callback('/([A-Z]{1})/', function ($matches) { return '_' . strtolower($matches[0]); }, $str); return ltrim($str, "_"); }
转载于:https://www.cnblogs.com/yangjiayu/p/11157596.html
最后
以上就是简单小海豚最近收集整理的关于变量名下划线和驼峰互转的全部内容,更多相关变量名下划线和驼峰互转内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复