communication
 databases
 directories
 file handling
 html and code
 image editing
 image listing
 sessions and co
 string handling
 information
 forms
 apple stuff
 image handling
 array handling
 lixlpixel
php - snippets
google search terms detected and highlighted.
remove highlighting | keep highlighting
make snippet in "directories" - download "read dir and list"
 search
php - snippets

Valid CSS!

php webring logo
prev next
random list
join the Ring!

directories - read dir and list was created/last modified on Mon 06 Oct 2003 7:08 PM

<?php
  
//------->function read & list start
  
function read_dir ($root ,$filter ) {
   
$root_dir =opendir ($root );
   while (
$file_file =readdir ($root_dir )) {
    if (
is_dir ($file_file ) && $file_file != "." && $file_file != ".." && substr ($file_file ,0,strlen ($filter )) == $filter ) {
     
$mtime = filemtime($file_file);
     
$array = array ( "_" => " " ,$filter => "" );
     
$thefile =strtr ($file_file ,$array );
     echo
"<a href=\"" .$file_file ."\" title=\"last modified on ".date("D d M Y g:i A", $mtime)."\">" .$thefile ."</a>\n" ;
     echo
"<br>\n" ;
    }
   }
  }
  
//------->function read & list end
  
$user =getenv ("REMOTE_ADDR" );
  
$server =getenv ("SERVER_ADDR" );

  if (
$user != $server ) {
   
read_dir ("." ,"pub_" );
  } else {
   
read_dir ("." ,"priv_" );
  }
?>

learn more about some of the PHP functions used in this snippet: array, date, dir, echo, else, end, file, filemtime, function, getenv, is_dir, list, opendir, readdir, root, strlen, strtr, substr, time, while

view the GNU general license - view the GNU library license - search on PHPsnippets - see your code like this

 a lixlpixel.com site

go to PHParadise to get free PHP, Javascript and FlashMX code