0
我想生成slu of的頁面,類別等就像wordpress 讓我有頁面標題:「我的頁面標題」 然後轉義空白和特殊的字符,並生成像「我的頁面-title」 怎麼辦呢如何生成SEF slu or或網址
我想生成slu of的頁面,類別等就像wordpress 讓我有頁面標題:「我的頁面標題」 然後轉義空白和特殊的字符,並生成像「我的頁面-title」 怎麼辦呢如何生成SEF slu or或網址
這是產生蛞蝓
function slug($var){
$seoname = preg_replace('/\%/',' percentage',$var);
$seoname = preg_replace('/\@/',' at ',$seoname);
$seoname = preg_replace('/\&/',' and ',$seoname);
$seoname = preg_replace('/\s[\s]+/','-',$seoname); // Strip off multiple spaces
$seoname = preg_replace('/[\s\W]+/','-',$seoname); // Strip off spaces and non-alpha-numeric
$seoname = preg_replace('/^[\-]+/','',$seoname); // Strip off the starting hyphens
$seoname = preg_replace('/[\-]+$/','',$seoname); // // Strip off the ending hyphens
$seoname = strtolower($seoname);
return $seoname;
}
功能