the following is code i wrote to grab news headlines within a <h2> tag to output
Code: Select all
$fp = fopen('http://www.trinidadexpress.com','r');
$content = fread($fp,15000);
fclose($fp);
$exp = "`(<h2[.*>]+>(\\n|.*)<\/h2>)<font[.*>]+>(\\n|.*)<\/font>|(<p[.*>]+>(\\n|.*)<\/p>)`i";
$news = preg_match_all($exp,$content,$headlines);
echo $news.'<br>';
for($i=0;$i<=count($headlines);$i++){
echo $headlines[$i][0].'<br>';
echo $headlines[$i][1].'<br>';
}i take it my expression is wrong but what exactly is the incorrect factor here??
Kendall