Under normal circumstances, we can use fseek to read. The advantage is that it will not be read all at once. The following code is only suitable for fetching and processing at the same time, and is not suitable for one-time reading and one-time processing.
You can use the following method to generate test files
Copy the code The code is as follows:
$file_handle = fopen("./csdn.txt", "rb+");
for ($index1 = 1; $index1 <= 2000000; $index1++) {
fwrite($file_handle , 'http://jb51.net'.$index1."r");
}
fclose($file_handle);
The reading processing code is as follows:
Copy code The code is as follows:
$i = 0;
$now = '';
while ($i >= 0) {
if ($i>10) {
break;
}
fseek($file_handle, 0, SEEK_CUR);
$now = fgetc($file_handle);//You can write your own judgment false to indicate the end of the file
if ($now == "r") {
using using use using using using using using use using ’’s ’ use to ‐ return to end‐‐‐‐‐‐ if ($now == "r") {
$now;
$i++;
}
fclose($file_handle);
http://www.bkjia.com/PHPjc/328032.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328032.htmlTechArticleUnder normal circumstances, we can use fseek to read. The advantage is that it will not be read all at once. The following code only It is suitable for processing while taking, but not suitable for one-time reading and one-time processing. Can...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn