Enter a search term check the script type and click submit. To search for a general category for example to find all results for scripts working with text files or file manipulation enter file or curl. Same for directory, sql etc. Otherwise use specific terms.
Here is the script you requested.
scripts/directory-read-file-lines.txt: 1271 bytes
read directory return links with first line of file as description
directory search file manipulati
on read and dis[;ay directory contents
directory links read line files
directory_read_file_lines D
ate added Jan 2013
<?php
$dir="scripts";
// read all html file in the current directory
if
($dh = opendir($dir)) {
$files = array();
while (($file = readdir($dh)) !== false) {
if (substr($file, strlen($file) - 4) == '.txt') {
array_push($files, $f
ile);
}
}
closedir($dh);
}
// Sort the files and display
sort($files);
//$files=array_unique($files);
$trimsubdir = explode("/",$dir);
$subdir=$
trimsubdir[1];
echo $subdir;
echo "<ul>";
foreach ($files as $file) {
$fh = fopen(
"$dir/$file", 'r');
$theData = fread($fh, 280);
fclose($fh);
$title = Title($file);
ec
ho "<li><a href=\"$dir/$file\" title=\"$theData\">$theData</a></li>\n";
}
echo "</ul>";
// Function to get a human readable title from the filename
function Title($filename) {
$title = substr($filename, 0, strlen($filename) - 5);
$title = str_replace('-', ' ', $ti
tle);
$title = ucwords($title);
return $title;
}
?>
Post a comment
No comments yet