function convert($raw) {
$new = preg_replace("![^a-z0-9]+!i", "-", $raw);
return $new;
}
当我运行它时,该功能将“男孩”变成“男孩”,但我想要“男孩”如何修改正则表达式以解决这个问题?
谢谢!
答案 0 :(得分:1)
function convert($raw) {
$new = preg_replace("![^a-z0-9]+!i", "-", $raw);
$new = rtrim($new,'-');
return $new;
}
答案 1 :(得分:0)
检查一下它工作正常
function convert($raw) {
$new = preg_replace("![^a-z0-9]+!i", " ", $raw);
return $new;
}
$data ="a - boy";
echo convert($data);