我想将一个字符串清理成一个URL,这是我基本需要的。
>除字母数字字符和空格之外,所有内容都必须删除,并被划分。
>空格应该是转换成破折号。
例如。
- This,is the URL!
必须返回
- this-is-the-url
谢谢
- function slug($z){
- $z = strtolower($z);
- $z = preg_replace('/[^a-z0-9 -]+/','',$z);
- $z = str_replace(' ','-',$z);
- return trim($z,'-');
- }