// 驼峰写法 function toUp ($str) { return preg_replace_callback('/\s(\w)|-(\w)/', function ($matches) { if (count($matches) > 2) { return strtoupper($matches[2]); } return strtoupper($matches[1]); }, $str); }
// 驼峰写法 function toUp ($str) { return preg_replace_callback('/\s(\w)|-(\w)/', function ($matches) { if (count($matches) > 2) { return strtoupper($matches[2]); } return strtoupper($matches[1]); }, $str); }
转载于:https://www.cnblogs.com/CyLee/p/8945147.html