Developers normally use functions that use Regular Expression to convert under_scored strings in to CamelCased strings. Usage of Regular Expression is quite heavy. We can use a simple yet powerful method to convert these strings to CamelCase without using RegEx in PHP.
Here is the method:
echo join(””, array_map(“ucwords”, explode(‘_’, $under_scored)));
This combination of functions, first explodes the underscored string in to an array containing sub strings formed by “_” delimiter and applies ucwords() function to each member of the array. ucwords() uppercases the first character of the string. These uppercased strings are again joined back to form a single string which is the CamelCased version of the actual string.
Please let me know if you have any questions.