php中的file函数

来源:互联网 发布:比特彗星监听端口堵塞 编辑:程序博客网 时间:2024/05/18 06:54

        最近用html的form把txt文件上传到了服务器, 然后想解析文件的每一行, 便于使用, 我居然去用file_get_ contents获取了一个整串, 然后自己又将每一行解析为数组。 真是费力不讨好啊。

       php提供了更加直接的函数, 也就是file,  直接看w3school的列子吧:

例子

<?phpprint_r(file("test.txt"));?> 

输出:

Array([0] => Hello World. Testing testing![1] => Another day, another line.[2] => If the array picks up this line,[3] => then is it a pickup line?)

0 0
原创粉丝点击