0
當我使用這個函數來過濾一些字符時,我所有的鏈接都從html頁面中刪除。爲什麼我的鏈接消失了?
這是代碼。
function AD($str)
{
# Quotes cleanup
$str = ereg_replace(chr(ord("`")), "'", $str); # `
$str = ereg_replace(chr(ord("´")), "'", $str); # ´
$str = ereg_replace(chr(ord("„")), ",", $str); # „
$str = ereg_replace(chr(ord("`")), "'", $str); # `
$str = ereg_replace(chr(ord("´")), "'", $str); # ´
$str = ereg_replace(chr(ord("「")), "\"", $str); # 「
$str = ereg_replace(chr(ord("」")), "\"", $str); # 」
$str = ereg_replace(chr(ord("´")), "'", $str); # ´
$str = ereg_replace(chr(ord("’")), "'", $str); # '
$unwanted_array = array( 'Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
'Ê'=>'E', 'Ë'=>'Ë', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'ë', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y');
$str = strtr($str, $unwanted_array);
# Bullets, dashes, and trademarks
$str = ereg_replace(chr(149), "•", $str); # bullet •
$str = ereg_replace(chr(150), "–", $str); # en dash
$str = ereg_replace(chr(151), "—", $str); # em dash
$str = ereg_replace(chr(153), "™", $str); # trademark
$str = ereg_replace(chr(169), "©", $str); # copyright mark
$str = ereg_replace(chr(174), "®", $str); # registration mark
return $str;
}
此外,我正在使用此其他代碼來過濾內容。
$ mycontent = AD($ row ['post_content']);
$mycontent = substr($mycontent,0,450);
$mycontent = preg_replace("/\[caption.*\[\/caption\]/", '', $mycontent);
$mycontent = strip_tags($mycontent);
爲什麼我的鏈接沒有顯示在帖子中?在我的cms中,他們顯示在帖子中,但他們沒有。
通過鏈接你的意思'' ...標籤? – JJJ
一開始,'strip_tags'會去除你內容中的每一個html標籤......閱讀文檔http://php.net/manual/en/function.strip-tags.php – Endophage