- preg_replace_callback: documentation ( source)
- strtoupper: documentation ( source)
<?php
$str = "abc_def_ghi_jkl";
$str = preg_replace_callback("/(?:^|_)([a-z])/", $str, function($matches) {
return strtoupper($matches[1]);
});
echo $str;