天天看点

html标签提取,提取HTML标签分享

function tags($filename,$tag) {

$buffer = join("",file($filename));

$buffer = eregi_replace("rn","",$buffer);

$tagkey = sql_regcase($tag);

$buffer = eregi_replace("

$ar = split("n",$buffer);

foreach($ar as $v) {

if(! eregi("

eregi("]*)((.*)$tagkey)?",$v,$regs);

$p[tagName] = strtoupper($tag);

if($regs[3])

$p[Text] = $regs[3];

$s = trim(eregi_replace("[ t]+"," ",$regs[1]))." ";

$s = eregi_replace(" *= *","=",$s);

$a = split(" ",$s);

for($i=0;$i

$ch = array();

if(eregi("=["’]",$a[$i])) {

$j = $i+1;

while(!eregi("["’]$",$a[$i])) {

$a[$i] .= " ".$a[$j];

u