- var_dump: documentation ( source)
- preg_replace_callback: documentation ( source)
- strtoupper: documentation ( source)
<?php
$s = '123_abc____def';
var_dump(
preg_replace_callback(
'/\_+[a-zA-Z]{1}/e',
function($matches){return '_' . strtoupper($matches[1]);},
$s)
);