Php reads txt files row-by-row and writes them to an array ,. Php's method of reading txt files and writing arrays row by row is original. This article describes how php reads txt files and writes arrays row by row. Share it with you for your reference. The specific method is as follows: assume that php reads txt files row by row and writes the array,
This example describes how php reads txt files row by row and writes them to an array. Share it with you for your reference. The details are as follows:
Assume that the user.txt file is as follows:
User01user02user03user04user05user06user07user08user09user10user11user12
Read user.txt one by one and write the array as follows:
$ File = fopen ("username.txt", "r"); $ user = array (); $ I = 0; // output all rows in the text until the end of the file. While (! Feof ($ file) {$ user [$ I] = fgets ($ file); // The fgets () function reads a row from the file pointer $ I ++ ;} fclose ($ file); $ user = array_filter ($ user); print_r ($ user );
Solve the problem!
I hope this article will help you with php programming.
The example in this article describes how php reads txt files row by row and writes them to an array. Share it with you for your reference. The details are as follows: Suppose there are...