📜  php 字符串下划线转换成驼峰式 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:28.235000             🧑  作者: Mango

代码示例2
function dashesToCamelCase($string, $capitalizeFirstCharacter = false) 
{

    $str = str_replace(' ', '', ucwords(str_replace('-', ' ', $string)));

    if (!$capitalizeFirstCharacter) {
        $str[0] = strtolower($str[0]);
    }

    return $str;
}

echo dashesToCamelCase('this-is-a-string');