我似乎无法preg_replace()
更改为preg_replace_callback()
.
为了使数据库表列在显示时更加人性化,我尝试用空格替换下划线并使每个单词都以大写字母开头。
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;
}