Php reads the content in the TXT file in order of the number of rows. each line in the txt file stores an IP address, which is now requested by different computers. each request is read in order of the number of rows. how can this problem be written? ------ Solution -------------------- what is a request from a different computer? ------ Solution ---------------------- reference: Reference: according to the meaning of the landlord: PHP & nbsp; code $ conts & php read the contents of the TXT in order of the number of lines
Each line in the txt file stores an IP address.
Currently, different computer requests are used to read data in the order of the number of rows.
How to write this?
------ Solution ----------------------
What is a request from a different computer?
------ Solution ----------------------
Reference:
Reference:
According to the meaning of the landlord:
PHP code
$ Conts = file_get_contents ($ filename );
$ ArrConts = explode ("\ n", $ conts );
Foreach ($ arrConts as $ cont ){
$ Pos = strpos ($ cont, $ _ SERVER ['remote _ ADDR ']);
If ($ pos = ......
$ Filename = "/root/a.txt ";
But there is a difference with #4. wait for other experts to eat first!
------ Solution ----------------------
Reference:
Reference:
What is a request from a different computer?
It is possible that three or more computers need to read the contents in the txt file at the same time, and the ip addresses read by different computers are the same.
Are the ip addresses read by different computers the same? So you want computer a to read 1 Computer B to read 2 computer c to read 3?
Go to the database.
------ Solution ----------------------
$num = 0;
if(file_exists('count.txt')) $num = file_get_contents('count.txt');
$ar = file('ip.txt');
echo $ar[$num++];
file_put_contents('count.txt', $num, LOCK_EX);