开发者

how to take data in txt files such as mysql?

(my first language is no english) i want to take data in txt files line by line.

Example:(This is my txt files)

exampleline1
exampleline2
exa开发者_C百科mpleline3
exampleline4

(1)i want to select all lines and print. How to?

(2)For example i want to print line 4. How to?


$lines = file("file.txt");
foreach($lines as $line){
  echo $line."<br>";
}

to print line 4

echo $lines[3];


use (But be careful not to waste your memory):
file_get_contents
fgets
file


use function file(); which returns array (line by line)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜