Convert Dashes to CamelCase in PHP

前端 未结 25 1196
南笙
南笙 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条回答
  • Alternatively, if you prefer not to deal with regex, and want to avoid explicit loops:

    // $key = 'some-text', after transformation someText            
    $key = lcfirst(implode('', array_map(function ($key) {
        return ucfirst($key);
    }, explode('-', $key))));
    
    0 讨论(0)
提交回复
热议问题