有人能帮我解决这个错误吗?
警告:preg_replace():不再支持/e修饰符,请改用preg_replace_callback
我的原始代码:
$match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
那么我试着这样做:
$match[1] = preg_replace_callback('/(?<=^|[\x09\x20\x2D])./e',
function ($matches) {
foreach ($matches as $match) {
return strtoupper($match);
}
},
strtolower(trim($match[1])));
但我仍然得到相同的错误:
警告:preg_replace_callback():/e修饰符不再受支持,请使用preg_replace_callback代替
preg_replace_callback()
代码中,e
修饰符已经没有意义了,可以去掉。另外,在foreach
中使用return
会在第一次迭代时停止循环。 - Syscall