dongpu8935 2013-05-08 13:34
浏览 64

我可以将多个链接传递给fopen,fread和feof吗?

I have the following function :

    function doParse($parser_object) {
    $links=file("./fullsoccer.TXT", "r");
    $i=0;
    while(!empty($links[$i]))
    {
        set_time_limit(0);
        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++;
    }
}

This code save a list of 507 links of XML data from fullsocce.txt into $links then I read the content of each file (link: online links) using fread and pass the $data to my main function which is xml_parse to parse and save the data using SAX parser . my problem is: just that last file of the array $links is passed to the function and parse the data , I want your help to know why it is working just with one file? please It is an emergency case

  • 写回答

2条回答 默认 最新

  • duanche2007 2013-05-08 13:48
    关注
    !($fp = fopen($links[$i], "r")
    

    fopen returns FALSE on error so this check is only true at eof or an invild line. Maybe changing it to

     if (($fp = fopen($links[$i], "r") != FALSE)
    

    I also noticed an extra ; and ) in if (!($fp = fopen($links[$i], "r"))); Maybe I'm just not matching properly.

    评论

报告相同问题?

悬赏问题

  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn