PDA

View Full Version : PHP help = Get files inside the folder



binladun
June 22nd, 2003, 12:54
Hello !

This is a perl - I know how to use it - Someone please help me to convert it to PHP

opendir(DIR, "/path/memeber");
@array = grep(/\.txt/./\.html/,readdir(DIR));
closedir (DIR);

$total_file = @array;


Thanks !
PS: I'm learning PHP by convert Perl code to PHP code

keith
June 22nd, 2003, 13:06
try this:
<?php

$dir = "files";

$files = array();
$open = opendir($dir);
while ($file = readdir($open)) {
if (!ereg("^\.",$file)) $files[] = $file;
}
closedir($open);
reset($files);

?>