Reply to readdir question

Your name:

Reply:


Posted by Brian on 10/13/84 11:26

Hi all

Below is a bit of code that puts the file list of a dir
into an array which I use later.

2 questions.......

1) how do I get the loop to only show files and not other directories?

2) Quite sure this can't be done other wise hacking would be so easy,
but is it possible to read the dir on a different server, and get the file
list
in date order of creation?

Thanks

Brian




if ($handle = opendir($path)) {
$thefiles = array();
while (false !== ($file = readdir($handle))) {
$ext = strrchr( $file, '.' );
if ( $ext == '.zip' || $ext == '.csv' || $ext == '.txt' || $ext ==
'.doc' || $ext == '.jpg' || $ext == '.bmp'
|| $ext == '.gif' || $ext == '.php' || $ext == '.htm' || $ext ==
'.html' || $file !== 'fileviewer.php') {
$thefiles[] = $file;
}
}
closedir($handle);
rsort($thefiles);
reset($thefiles);
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация