I have a file (fullsoccer.txt) which has 500 links (online links for XML files) I call those links and then I pass each one to a function that open the link then read the content and then passing the content to parsing function (xml_parser) to parse the content and save it in my database. my problem is that the function is parsing and saving the last file only. I try to debug the code and find that all links are right and being opened but just the last one is being parsed I need your help on this is the problem with my code? or does fopen and fread in my loop receiving the second opening request before finishing the first reading request? this is my code:
function doParse($parser_object) {
$links=file("./fullsoccer.TXT");
foreach($links as $link)
{
set_time_limit(0);
//echo 'reading '.$link."\n";
$fp = fopen($link, "r");
if ($fp!==false)
{
//loop through data
while ($data = fread($fp, 4096)) {
//parse the fragment
xml_parse($parser_object, $data, feof($fp));
//echo $data;
}
//echo "\n";
fclose($fp);
} else {
echo 'Cannot Open Link '.$link."\n";
}
}
}
help my on this because I have been living with it for really a long time, please