入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

php中的file函数

创建时间:2016-03-05 投稿人: 浏览次数:2573

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

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

例子

<?php
print_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?
)

声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。