php一行行读取文件每行组装成数组(从第三行开始读)

public function readFile($path){
$data = array();
$returnTxt = ''; // 初始化返回
$i = 1;
$fh = fopen($path,"r");
while (!feof($fh)){
$line = fgets($fh, 4096);
if($i>=3 && !empty($line)){
$returnTxt = $line;
$str = iconv('GB2312','UTF-8',$returnTxt);
$arr = explode(',',$str);
$data[] = $arr;
}

$i++;
}

fclose($fh);

}

$path="文件路径";

readFile($path);

猜你喜欢

转载自www.cnblogs.com/lsbaiwyl/p/9020041.html
今日推荐