- preg_replace_callback: documentation ( source)
<?php
function camelCase($string) {
//preg_replace('/[^a-zA-Z0-9]/', '', ucwords(str_replace('/',' ',strtolower($string))));
//return preg_replace_callback('/\/[a-zA-Z9-0]/', function($matches){return strtoupper($matches[0][1]);}, $string);
return preg_replace_callback('/\/[a-zA-Z9-0]/', function($matches){return ucword($matches[0]);}, $string);
return $string;
}
echo camelCase('common/home');