Use File_get_contents () to get the contents of the TXT file, and then convert the obtained string to an array by explode ().
Get array length You can use the count () function
<?PHP$file= ' Keywords.txt ';$content=file_get_contents($file);//echo $content;$array=Explode("\ r \ n",$content);//Print_r ($array); for($i= 0;$i<Count($array);$i++){Echo $array[$i].‘ <br/> ';} ?>
About line breaks in TXT documents
In the regular expression, there is a \ n is the meaning of newline, and a \ R is the meaning of carriage return.
When working with a string or console output, it can be wrapped in any line.
But in TXT, which is not the standard line-break, only the combination of \ r \ n is a newline (for the entire Windows default line-wrapping, this is the case).
It means that the line is over, the cursor goes back to the head, and then it moves down a line to a new line.
About File_get_contents ()
The file_get_contents () function reads the entire file into a string.
The file_get_contents () function is the preferred method for reading the contents of a file into a string. If supported by the operating system, memory-mapping techniques are also used to enhance performance.