更新时间:2023-02-21 19:56:38
我目前使用此功能很满意
function url($url) {
$url = preg_replace('~[^\pL0-9_]+~u', '-', $url);
$url = trim($url, "-");
$url = iconv("utf-8", "us-ascii//TRANSLIT", $url);
$url = strtolower($url);
$url = preg_replace('~[^-a-z0-9_]+~', '', $url);
return $url;
}
它将空格和其他奇数字符替换为-
,因此结果将为peter-s-pet-shop-washing