本文介绍了用php读取纯文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的服务器中有一个包含此信息的文本文件:
I have a text file with this information in my server:
Data1 Data2 Data3 . . . DataN如何使用PHP(逐行)读取文本文件中的所有信息?
How do I read all the information from the text file (line by line) using PHP?
推荐答案<?php $fh = fopen('filename.txt','r'); while ($line = fgets($fh)) { // <... Do your work with the line ...> // echo($line); } fclose($fh); ?>
这将使您逐行阅读..阅读有关行尾的 php/fgets 上的注释Mac问题.
This will give you a line by line read.. read the notes at php/fgets regarding the end of line issues with Macs.
更多推荐
用php读取纯文本文件
发布评论