PHP驼峰转下划线
/**
* @notes: 驼峰转下划线
* @param string|null $string
* @return string
*/
function convert_to_underscore(string|null $string)
{
if (empty($string)) {
return '';
}
$pattern = '/([a-z])([A-Z])/';
$replacement = '${1}_${2}';
return strtolower(preg_replace($pattern, $replacement, $string));
}

浙公网安备 33010602011771号