Three homepage news releases to make updates easier for you (middle)
Last time we made a file header (as for the file tail, please make it yourself, assuming it is tail.php), a function module, now , let’s implement a basic function, that is, dynamic publishing
include("makestr.php";
include("head.php");
$newspath="/announce/"; //Directory of news files stored in text files
$newsfile=array();//Prepare news array
$hd=dir($newspath); //Directory Handle
while($filename=$hd->read()){ //Get all files
$s=strtolower($filename);
if(strstr($s,".txt" )){
//Detect the latest modification date
$lastchanged=fileatime($newspath.$filename);
$newsfile[$filename]=$lastchanged;
}
}
arsort($newsfile); //Sort files by time
//Output file
for(reset($newsfile);$key=key($newsfile);next($newsfile))
{$fa=file($newspath.$key);
$n=count($fa);
echo "
".date("d.m.Y-H:i:s".$newsfile [$key])."
n";
for($i=0;$i<$n;$i=$i+1){
$s=chop($fa[ $i]);//Remove spaces
$s=htmlspecialchars($s);
print $s."