I have a 500 link to xml files (online files) I want to pass those files to a function that read the content of these files, parse them and then store them in my database (mysql). I use this function to get the links:
function get_links()
{
$user_file = @fopen("./fullsoccer.TXT", "r");
if ($user_file)
{
while (!feof($user_file))
{
$lines[] = fgets($user_file, 4096);
}
fclose($user_file);
}
return $lines;
}
then I use this function to read each link content and parse it :
function doParse($parser_object) {
$links=get_links();
$i=0;
while(!empty($links[$i]))
{
if (!($fp = fopen($links[$i], "r")));
{
//loop through data
while ($data = fread($fp, 4096)) {
//parse the fragment
xml_parse($parser_object, $data, feof($fp));
}
}
$i++;
}
}
The links are returned successfully (I print them in the "doParse" function) but the problem is : the "doParse" function just parse the file of the last link. I want to know why the function parse just the file of the last link and leave the whole previous 499 files ? is it fopen problem ?? does it able of reading more than 1 file?