I had to come up with a way to convert array keys using undescores (underscore_case) into camelCase. This had to be done recursively since I did not know what arrays will be
Try preg_replace_callback():
$key = preg_replace_callback('/_([a-z]*)/', function($matches) {
return ucfirst($matches[1]);
}), $key);
A couple notes:
[a-z] because [A-Z] will already be capitalized* 0+ repetition was used in case we have a situation like camel_$case, I assumed that the _ should still be replaceducfirst() on the first match group