PHP Snippets
Name:viewfiles()
Description: Echo all files from the specific directory.
Code below...
>
<?php
function viewfiles($path){
$ff = array();
if ($dir = @opendir("./$path")){
while (false !== ($file = readdir($dir))) {
if ($file != "." && $file != "..") {
$ff[] = $file;
}
}
closedir($dir);
}
$result = implode("<br/>",$ff);
return $result;
}
//Here's an example
$dir_path = "/directory/path/here";
$files = viewfiles($dir_path);
echo $files;
?>
function viewfiles($path){
$ff = array();
if ($dir = @opendir("./$path")){
while (false !== ($file = readdir($dir))) {
if ($file != "." && $file != "..") {
$ff[] = $file;
}
}
closedir($dir);
}
$result = implode("<br/>",$ff);
return $result;
}
//Here's an example
$dir_path = "/directory/path/here";
$files = viewfiles($dir_path);
echo $files;
?>