Ati*_*din 19 php regex sanitization preg-replace
我想清理URL中的字符串,这是我基本上需要的.
例如.
This, is the URL!
Run Code Online (Sandbox Code Playgroud)
必须回来
this-is-the-url
Run Code Online (Sandbox Code Playgroud)
Sil*_*ost 42
function slug($z){
$z = strtolower($z);
$z = preg_replace('/[^a-z0-9 -]+/', '', $z);
$z = str_replace(' ', '-', $z);
return trim($z, '-');
}
Run Code Online (Sandbox Code Playgroud)