How to use php (as the current mainstream development language) to directly call the content of a text file: first open a text file on the server through the file function, and the returned $myFile will become the file operation handle, and then use the loop command to take out the content of each line in the file and print it out.
Programming Ideas
The first function to use is fi1e. This function is similar to readfile(). The difference is that the file function reads all the contents of the file and outputs it to the array. Each row in the variable is a separate array element. Use the file function to open a data.txt file. The content of the data.txt file is:
First line 1
Second line 2
Third line 3
The statement to open the file is: $myFile=file("data.txt"); At this time, $myFile is an array variable.
Then print out the contents of each element of the array by looping through the array through the loop instruction. The count() function used here is used to
get the number of array elements. The statement to print the contents of the array is: print($myFile[$index]." ").
Creation steps
1. Use the file function to open the file
The following is a quote:
$myFile=file("data.txt");
2. Loop through the array and print the elements of the array
Here, through
the following is a reference fragment:
for($index=0;$index
for($index=0;$index ; Print it out.
3. Program code
The following is a quotation fragment:
http: //www.bkjia.com/PHPjc/508901.html