开发者

create SEO links in PHP

what is the best preg_replace to create an SEOed text to be used in uri ??

i mean like if we had this uri http://t.com/SOME RANDOM $#@ TEXT _ + ?/ =\ , what is best preg_replace expression to clean it up ?

Thank you .

EDIT : assuming y开发者_JS百科ou have multiple languages in the random text language ??


Do you mean a slug?

Slug('SOME RANDOM $#@ TEXT _ + ?/ =\\'); // some-random-text

For that this should be enough:

function Slug($string, $slug = '-')
{
    return strtolower(trim(preg_replace('~[^0-9a-z]+~i', $slug, $string), $slug));
}


I guess what you're looking for is URL sanitizing. Here's a link to a filter for php: http://php.net/manual/en/filter.filters.sanitize.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜