最近用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? )

![[手游] 三网H5小游戏【少年仙路】WIN系服务端+Linux手工服务端+详细搭建教程](https://cdn.jxasp.com:9143/image/20260615/136BC33AA47EB0D84E878835A8B38FDB.png)

















