PHP一则字符串转为标准SEO URL的正则表达式 09 April 2011 16:02 Saturday by 小屋 分享收藏

标签: 字符串

一则把不规范的字符串转为用横杠隔开的标准的SEO的URL的正则表达式

$str    = '/The-URL-\//string-to-/the,-standard-SEO@html';
echo trim(preg_replace('/\-(?=\-)/','',preg_replace('/[^\w\-]/','-',$str)),'-');
//转化后 The-URL-string-to-the-standard-SEO-html
作者: Sjolzy

--EOF--

引用地址:

发表评论:

  给 “PHP一则字符串转为标准SEO URL的正则表达式” 评分

广告、无意义的评论必删!