<?php
$fp = fopen("test.txt","r") ;
$file = fread($fp,filesize("test.txt"));
ereg("<p align=\"center\"></font>[.\xA0-\xFF]*</td></tr>",$file,$subject);
$sub = substr($subject[0],25,-10);
ereg("<td width=\"100%\" height=\"19\" bgcolor=\"#F1FAE2\">[.\n\xA0-\xFF]*</td>",$file,$contect);
$cont = substr($contect[0],47,-5);//显示
echo "题目:<font color=red>".$sub."</font><br>内容:<font color=green>".$cont."</font>";
?>
$fp = fopen("test.txt","r") ;
$file = fread($fp,filesize("test.txt"));
ereg("<p align=\"center\"></font>[.\xA0-\xFF]*</td></tr>",$file,$subject);
$sub = substr($subject[0],25,-10);
ereg("<td width=\"100%\" height=\"19\" bgcolor=\"#F1FAE2\">[.\n\xA0-\xFF]*</td>",$file,$contect);
$cont = substr($contect[0],47,-5);//显示
echo "题目:<font color=red>".$sub."</font><br>内容:<font color=green>".$cont."</font>";
?>
$fp = fopen("test.txt","r") ;
$s = fread($fp,filesize("test.txt"));
fclose($fp);
$s = = ereg_replace("\r?\n","",$s); // 删除可能的换行
preg_match_all("/>([^<>]*)</",$s,$regs); // 匹配
$out = array_filter($regs[1]); // 滤除空项,得到结果
?>
按你给出的例子,结果为:
Array
(
[8] => 题目题目题目题目题目题目
[12] => 内容内容内容内容内容内容内容内容
[24] => 主页
)