Php > File Manipulation
Another script to display news from files in a directory
Another script to display news from files in a directory This version does not use the UNIX ls command and works also on Windows NT
News
News
".$linktext. "".$b; } } return($s); } // change this to the directory of your news files // they should be plain ASCII text files with extension ".txt" $newspath = "c:\\apache\\htdocs\\news\\"; // Declare array to hold filenames $newsfile = array(); // Create handle to search directory $newspath for files $hd = dir($newspath); // Get all files and store them in array while( $filename = $hd->read() ) { $s=strtolower($filename); if (strstr($s, ".txt")) { // Determine last modification date $lastchanged=filemtime($newspath.$filename); $newsfile[$filename] = $lastchanged; } } // Sort files in descending order arsort($newsfile); // Output files to browser for(reset($newsfile); $key = key($newsfile); next($newsfile)) { $fa = file($newspath.$key); $n=count($fa); print "
\n"; print "
".date( "d.m.Y - H:i:s",$newsfile[$key]). "
\n"; for ($i=0; $i<$n; $i=$i+1) { $s=chop($fa[$i]); $s=htmlspecialchars($s); $s=createurl($s); print $s. "
\n"; } print "
"; } $hd->close(); ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage