file()函数可以将整个文件读入数组,并且数组中的每个元素都是文件中的对应行,包括换行符。
array file ( string $filename [, int $flags = 0 [, resource $context ]] )
<?php
print_r(file("/PhpProject/sample.txt"));
?>输出结果
Array ( [0] => (cainiaoplus.com) [1] => www.cainiaoplus.com [2] => TP )