逐行讀取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);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM