Read file lines backwards (fgets) with php

前端 未结 4 1889
轮回少年
轮回少年 2021-01-17 18:03

I have a txt file that I want to read backwards, currently I\'m using this:

$fh = fopen(\'myfile.txt\',\'r\');
while ($line = fgets($fh)) {
  echo $line.\"         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 18:48

    Try something simpler like this..

    print_r(array_reverse(file('myfile.txt')));
    

提交回复
热议问题