I can't seem to get the preg_replace()
to change to preg_replace_callback()
.
In an attempt to make database table columns more human-friendly when I display them, I am trying to replace underscores with spaces and make every word start with a capital letter.
function tidyUpColumnName($_colName) {
// Check for blank and quit
if(empty($_colName)) return false;
// Replace underscore and next lowercase letter with space uppercase and Capitalise first letter
$newColName = ucfirst(preg_replace_callback('/_[a-z]/uis', '" ".substr(strtoupper("$0"), 1)', $_colName));
return $newColName;
}