Code: Select all
if ($type =="file"){
while (($file = readdir($this->dh)) !== false) {
if ( $file != "." && $file != ".." ){
if (is_file($file)){
$files[] = $file;
}
}else{
$junk[] =$file;
}Moderator: General Moderators
Code: Select all
if ($type =="file"){
while (($file = readdir($this->dh)) !== false) {
if ( $file != "." && $file != ".." ){
if (is_file($file)){
$files[] = $file;
}
}else{
$junk[] =$file;
}Code: Select all
<?php
if ($type =="file"){
while (($file = readdir($this->dh)) !== false) {
if ( $file != "." && $file != ".." ){
if (is_file($file)){
$files[] = $file;
}
}else{
$junk[] =$file;
}// ene elese
}// end loop
}
?>Code: Select all
class dynamicdir {
var $directory;
var $path;
var $dh;
var $readable;
var $writable;
var $executable;
function dynamicdir($path, $directory){
$this->path = $path;
$this->directory = $directory;
if (is_dir($this->path.$this->directory)) {
$this->dh = opendir($this->path.$this->directory);
}
if ($this->dh){
return $this->dh;
} else {
}
}//end constructor function
function directorylist($exclude, $type){
if ($type =="file"){
while (($file = readdir($this->dh)) !== false) {
if ( $file != "." && $file != ".." ){
if (is_file($file)){
$files[] = $file;
}
}else{
$junk[] =$file;
}// ene elese
}// end loop
} else if ($type == "dir"){
while (($file = readdir($this->dh)) !== false) {
if ($file != "." && $file != ".." && !is_file($file)){
$files[] = $file;
}
}
} else{
}
return $files;Code: Select all
$dir = new dynamicdir ("/some/absolute/path/","Some_directory");
$files = $dir -> directorylist("", "file");
print_r($files);Code: Select all
tags ...
$file in the function is strictly the filename, not the path.. is_file requires the path.Code: Select all
<?php echo "php tags" ?>Code: Select all
<?php echo "Thanks feyd, Sami, and hawleyjr"
?>