例如:
如何以最高效的方式使用PHP完成这个任务?
以下是我的建议:
abc-def-xyz
转为 abcDefXyz
the-fooo
转为 theFooo
等等。如何以最高效的方式使用PHP完成这个任务?
以下是我的建议:
$parts = explode('-', $string);
$new_string = '';
foreach($parts as $part)
$new_string .= ucfirst($part);
$new_string = lcfirst($new_string);
但我觉得这可以用更少的代码实现 :)
ps:祝大家节日快乐!! :D