In PHP if we want to replace all underscore connected letters to upper case then we can use the php function called "preg_replace_callback" .
For example if we have string "kp_o_zmq_k" then the output becomes "kpOZmqK".
See the example below:
$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], "_"));
}
Hope this helps!
0 Comment(s)