Converting snake_case to PascalCase Is there an effective way, maybe with regex, to change the following text pattern?

I have a string like abc_def_ghi_jkl. I want to replace it to AbcDefGhiJkl.  I currently use the following code to change it. Is there a more effective way than this?

implode('',array_map('ucfirst',explode('_',$string)));
More effective solution:

str_replace('_', '', ucwords($key, '_'));


From Gears library