Read the text file and display on the page in this article two kinds of reading text files and displayed in the PHP instance of the Web page, the method is very simple, with fopen, add explode,for to achieve.
Reads a text file and displays it in a Web page
This article is about two kinds of reading text files and displayed in the Web page PHP Tutorial instance, the method is very simple, with fopen, add explode,for on the implementation.
*/
$file = "./text.txt";
$text = Fread (fopen ($file, "R"), FileSize ($file));
$line = Explode ("R", $text);
echo "
"; for ($i = 0; $i <= count ($line), $i + +) {$txt = explode ("t", $line [$i]); echo "
". $txt [0]." |
". $txt [1]." |
". $txt [2]." |
". $txt [3]." |
"; } echo "
";
Method Two
$content = file_get_contents (' test.txt ');
$arr = Explode ("n", $content);
echo "
foreach ($arr as $v) {
$tmp = Explode ("", $v);
echo "
echo "
";
"; Echo"
" . $tmp [0]. " | "; Echo"
" . $tmp [1]. " | "; Echo"
" . $tmp [2]. " | "; Echo"
" . $tmp [3]. " | "; Echo"
"; unset ($tmp);}
";
In fact, there is not a way to implement the above example, the file function Oh, this I do not say much. Check it out, it reads the content directly to the data, it is not necessary for us to use the explode function.
/*
The text text format is as follows
Read the contents of a text file as follows
1 AAAA bbba Ccca
2 AAAA bbbb CCCB
3 AAAA bbbc CCCC
3 AAAA bbbc CCCC
http://www.bkjia.com/PHPjc/632048.html www.bkjia.com true http://www.bkjia.com/PHPjc/632048.html techarticle read the text file and display on the page in this article two kinds of reading text files and displayed in the PHP instance of the Web page, the method is very simple, with fopen, add explode,for to achieve. Read text ...