Hi Jay, thanks for the reply.
Well, here's the whole lot.
It works fine till I start trying to search for multiple terms in the outputnews or matchWords function.
Just don't know why. It's likely some kind of simple syntax thing as I'm new to php.
Again, any help would be much appreciated.
Cheers
B
Code: Select all
<?php
function loadFiles($fn){
$allPages = array();
for($x = 0; $x < count($fn); $x++){
$doc = domxml_new_doc("1.0");
$doc = domxml_open_file($fn[$x]);
$word = array();
$word = getTitles($doc);
$J = sizeof($word);
echo "this big: ".$J;
$allPages = array_merge($allPages, $word);
}
doHead("Twit");
outputNews($allPages);
doFoot();
}
function getTerms(){
$setTerms = ('Israel', 'bomb', 'monkey', 'drown');
return $setTerms;
}
function outputNews($w){
foreach($w as $tits){
if (matchWords($tits)){
echo "<BR>";
echo $tits->get_content();
echo "<BR>";
}
}
}
function matchWords($t){
$searchTerms = getTerms();
foreach($searchTerms as $tx){
if (strstr($t->get_content(), $tx)){
return 1;
}
return 0;
}
}
function getTitles($dn){
$title_array = $dn->get_elements_by_tagname("title");
return $title_array;
}
function doHead($name){
echo "<HTML><HEAD><TITLE>";
echo $name;
echo "</TITLE></HEAD><BODY>";
}
function doFoot(){
echo "</BODY></HTML>";
}
$f = array('http://rss.news.yahoo.com/rss/world', 'http://rss.news.yahoo.com/rss/topstories');
loadFiles($f);
?>
[/i]