逐行读取txt文件并存入到数组中


get_file_contents_on_line.php


  $file = fopen("log.txt", "r");
        $user=array();
        $i=0;
//输出文本中所有的行,直到文件结束为止。
        while(! feof($file))
        {
            $user[$i]= fgets($file);//fgets()函数从文件指针中读取一行
            $i++;
        }
        fclose($file);
        $user=array_filter($user);
        print_r($user);

猜你喜欢

转载自blog.csdn.net/w13707470416/article/details/85562354