Convert Dashes to CamelCase in PHP

前端 未结 25 1293
南笙
南笙 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:17

    $stringWithDash = 'Pending-Seller-Confirmation'; $camelize = str_replace('-', '', ucwords($stringWithDash, '-')); echo $camelize; output: PendingSellerConfirmation

    ucwords second(optional) parameter helps in identify a separator to camelize the string. str_replace is used to finalize the output by removing the separator.

提交回复
热议问题