Why my links are disappeared?
When i am using this function to filter some characters, all my links are removed from the html page.
this is the code.
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', 'ä'=>开发者_如何学Go'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;
}
Also i am using this other codes to filter the content.
$mycontent = AD($row['post_content']);
$mycontent = substr($mycontent,0,450);
$mycontent = preg_replace("/\[caption.*\[\/caption\]/", '', $mycontent);
$mycontent = strip_tags($mycontent);
Why my links are not showed in the posts? In my cms they are showed but in posts they are not.
The strip_tags
call is removing all HTML, including links. If you want to keep the links, then pass the second parameter to strip_tags
indicating that you want to keep <a>
:
$mycontent = strip_tags($mycontent, '<a>');
精彩评论