PHP: convertire una stringa in notazione camel case

PHP: convertire una stringa in notazione camel case

In PHP è semplice convertire una stringa in notazione camel case.

Possiamo implementare la seguente soluzione:


function to_studly_caps($str) {
    return str_replace(' ', '', ucwords(str_replace('-', ' ', $str)));
}
function to_camel_case($str) {
    return lcfirst(to_studly_caps($str));    
}

Torna su