使用Laravel读取文件内容 [英] Read file contents with Laravel

查看:3569
本文介绍了使用Laravel读取文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Laravel逐行读取文件的内容. 但是,我似乎在任何地方都找不到任何东西.

I am trying to read the contents of a file line by line with Laravel. However, I can't seem to find anything about it anywhere.

我应该使用fopen函数还是可以通过File :: get()函数来做到这一点?

Should I use the fopen function or can I do it with the File::get() function?

我已经检查过API,但似乎没有读取文件内容的功能.

I've checked the API but there doesn't seem to have a function to read the contents of the file.

推荐答案

您可以使用简单的PHP:

You can use simple PHP:

foreach(file('yourfile.txt') as $line) {
    // loop with $line for each line of yourfile.txt
}

这篇关于使用Laravel读取文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆