Convert Dashes to CamelCase in PHP

前端 未结 25 1326
南笙
南笙 2020-12-07 19:40

Can someone help me complete this PHP function? I want to take a string like this: \'this-is-a-string\' and convert it to this: \'thisIsAString\':

function d         


        
25条回答
  •  半阙折子戏
    2020-12-07 20:30

    function camelize($input, $separator = '_')
    {
        return lcfirst(str_replace($separator, '', ucwords($input, $separator)));
    }
    
    echo ($this->camelize('someWeir-d-string'));
    // output: 'someWeirdString';
    

提交回复
热议问题