1
我做了一个功能,用于从帖子标题中创建关键字并将全文中的每个单词替换掉。php preg_replace在发布帖子标题中创建seo链接的问题
这是我的功能
function myseonew($title,$text){
$title = stripslashes($title);
$text = stripslashes($text);
$fburl = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$keywords = explode(" ",$title);
$regex = '/('.implode('|', $keywords).')/i';
$output = preg_replace($regex, '<a id="smalltext" href="'.$fburl.'">\\1</a>', $text);
return $output;
}
,但我遇到一个问题,输出所有涉及的字符()。
那么有没有什么办法对了我的编码来解决这个问题
是UTF-8
问候
为什么你在用'stripslashes'吗?这通常意味着你在其他地方做了一些非常错误的事情。 – ThiefMaster
stripslashes不是问题,即使我删除它的问题仍然 –
你能告诉我们一个或多个示例输入('$ title'和'$ text')吗? –