- substr: documentation ( source)
- preg_replace_callback: documentation ( source)
<?php
$oldValue = 'new_name_spacing';
$newValue = preg_replace_callback(
'/(_[a-z])/',
function ($match) {
return substr($match, 1, strlen($match));
},
$oldValue
);
echo $newValue;