PHP操作文件

  public function log()
    {
        $file = fopen(PACK_PATH . "/ProjectImg_1902.log", "r");
        $myfile = fopen(PACK_PATH . "/url.txt", 'a') or die("Unable to open file!");

        while (!feof($file)) {
            $id = trim(str_replace('\r', '', fgets($file)));
            $res = strstr($id, 'www.bozhou.gov.cn');
            if (empty($res)) {
                continue;
            } else {
                $start = "data:";
                $end = ";msg";
                $str = $this->get_between($id, $start, $end);
                $data = json_decode($str, true);

                fwrite($myfile, $data['picUrl'] . "\r\n");
                //
            }

        }
        echo 'code died please reboot';
        fclose($myfile);
        exit();
    }

 

posted @ 2019-02-20 12:18  friendwrite  阅读(144)  评论(0编辑  收藏  举报