用php读取纯文本文件

编程入门 行业动态 更新时间:2024-10-12 10:17:50
本文介绍了用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读取纯文本文件

本文发布于:2023-10-12 04:37:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483734.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本文件   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!