<?php
/*
*
* 广告屏蔽
*
*
*/
function drop_ad($start,$end=false,$txt='',$con = false,$add = false){
global $html;
if ( $end === false){
$html = str_replace($start,'',$html);
}
if ( $con ){
if ( strpos($html,$con) === false ){
return;
}
}
$a = strpos($html,$start);
if ( $a === false ){
return;
}
$str1 = substr($html,$a);
$b = strpos($str1,$end);
if ( $b === false ){
return;
}
$str2 = substr($str1,$b+strlen($end));
$str1 = substr($html,0,$a);
if ( $add ){
$html = $str1.$start.$txt.$end.$str2;
}else{
$html = $str1.$txt.$str2;
}
}
if ( substr($url_A['host'],strlen($url_A['host'])-10) == '.3g.qq.com'){
//drop_ad('聊3GQQ时还可以:','
','');
drop_ad('<p align="left">','
','<p align="left">','title="3GQQ聊天-手机腾讯网"');
drop_ad('【热点新闻】','</p>','</p>');
}
怎么在上面的这个基础上用preg_replace()正则替换屏蔽页面的指定链接文字广告。比如说:qq空间及qq家园的文字广告,
http://c.gdt.qq.comhttp://tapp.3g.qq.comhttp://boss.qzone.qq.com
echo $str;