How to directly invoke the text file content in PHP: first through the file function to open a text file on the server, the returned $myfile will become the handle of the file operation, and then through the loop instruction, take out the contents of each line of the file and print out.
Programming Ideas
The first function to be used is fi1e, which is similar to ReadFile (), where the file function reads all the contents of the files and outputs them to the variable in the array, and each row is a separate array element. Open a Data.txt file using the file function, and the contents of the Data.txt file are:
First row 1
Second row 2
Third row 3
The statement to open the file is: $myFile =file ("Data.txt"), when $myfile is an array variable.
The contents of each element of the array are then printed by looping through the loop instruction in the arrays, and the function of count () is used here to
Gets the number of array elements. The statement that prints the contents of the array is: print ($myFile [$index]. " ")。
Authoring steps
First, use the file function to open files
The following is a reference fragment:
$myFile =file ("Data.txt");
Second, loop through the array, print the elements of the array
Here, by
The following is a reference fragment:
Prints the contents of the elements in the array at the same time.
Third, the program code
The following is a reference fragment:
http://www.bkjia.com/PHPjc/762038.html www.bkjia.com true http://www.bkjia.com/PHPjc/762038.html techarticle how to directly invoke the text file content in PHP: first through the file function to open a text file on the server, the returned $myfile will become the handle of the operation of the files, and then through ...