i have a text (text.txt) file like thi开发者_JS百科s:
shir
beer
geer
deer
i have also a php page with that source:
<?php
foreach (glob("*.txt") as $filename) {   
    $file = $filename;
    $contents = file($file); 
    $reverse = array_reverse($file, true);
    $string = implode("<br>" , $contents);
    echo $string;
    echo "<br></br>";
}
?>
I want that in the php page it will show:
deer
geer
beer
shir
from the end of the file to the beginning.
thank youLooks like you are reversing the file name and not the contents.
Do
$reverse = array_reverse($content); // you can drop 2nd arg.
$string = implode("<br>" , $reverse);
in place of
$reverse = array_reverse($file, true); 
$string = implode("<br>" , $contents);
Also you can remove the temp variables from you script and do:
foreach (glob("*.txt") as $filename) {   
    echo implode("<br>" , array_reverse(file($filename))) . "<br></br>";
}
<?php
foreach (glob("*.txt") as $filename) {   
    $file = $filename;
    $contents = file($file); 
    $reverse = array_reverse($contents, true);
    $string = implode("<br>" , $reverse);
    echo $string;
    echo "<br></br>";
}
?>
Your result was a $contents, without reverse.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论