Try with preg_replace_callback function in php.
$ptn = "/_[a-z]?/";
$str = "kp_o_zmq_k";
$result = preg_replace_callback($ptn,"callbackhandler",$str);
// print the result
echo $result;
function callbackhandler($matches) {
return strtoupper(ltrim($matches[0], "_"));
}
0
solved Converting all underscore connected letters to uppercase in php [closed]