The content of this article is php file operation-add the data of other files to this file, now share it with everyone, friends in need can refer to it
GitHub source code
In fact, our The program writes answers based on the following questions:
There are two text files A.txt B.txt
A.txt 30 million lines, userid is unique, userid and username are separated by spaces, as shown below:
userid username
1 yi yi
2 er er
3 san
… …
B.txt 30 million lines, userid is unique, userid and realname are separated by spaces, as shown below:
userid realname
1 ##userid realname
1 Go to the third column of B.txt and give the time complexity.
In our program, by default, the row data of the two files are in one-to-one correspondence, that is, the nth row of data in A corresponds to the nth row of data in B. In this way, the time complexity of our program is O(n).
Copy after login
In fact, our program is based on the following issues Written answer:
There are two text files A.txt B.txt
A.txt 30 million lines, userid is unique, userid and username are separated by spaces, as follows:
1 yi yi
2 er
3 san
… …
B.txt 30 million lines, userid is unique, userid and realname are separated by spaces, as shown below:
userid realname
1 一
2 二
3 三
… …
Please write a piece of code to find the username corresponding to the userid in B.txt in A.txt and fill it in B.txt The third column gives the time complexity.
In our program, by default, the row data of the two files are in one-to-one correspondence, that is, the nth row of data in A corresponds to the nth row of data in B. In this way, the time complexity of our program is O(n).
Copy after login
Get the directory for PHP file operations Files and methods of calculating relative paths
patch files PHP file operations to implement code sharing
The above is the detailed content of PHP file operation-add data from other files to this file. For more information, please follow other related articles on the PHP Chinese website!