Skip to content

Instantly share code, notes, and snippets.

@bjzhush
Created July 25, 2018 12:42
Show Gist options
  • Save bjzhush/874ed7596e4324c0a4577a37bfe651b8 to your computer and use it in GitHub Desktop.
Save bjzhush/874ed7596e4324c0a4577a37bfe651b8 to your computer and use it in GitHub Desktop.
流式读取大文件的方法
<?php
$lines = [];
$handle = fopen('x.txt', "r");
if (!$handle){
exit('error');
}
while(!feof($handle)) {
$line = trim(fgets($handle));
}
fclose($handle);
echo 'done';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment