PHP itself has a readdir function, but it can only read the current directory. Based on this function, I wrote another function to achieve my needs. The principle of the function is very simple, mainly using recursive calls.
The code is as follows
|
Copy code
|
||||||||
class listdir{
var $depth;
$this->tostring=””; $this->getlist($path); }else{ $this->list[$this->depth][]=$item;
}
}
}
$this->list[$this->depth]['directory']=$dir;
$this->depth-=1;
$d->close();
return $this->list;
}
//Character channeling result
function tostring($dir=""){
if($dir==””)$dir=$this->dirname;
$d=@dir($dir);
$this->tostring.=”
Related labels:
source:php.cn
Previous article:PHP regular expression verification email_PHP tutorial
Next article:Program to randomly generate a set of non-repeating numbers in PHP_PHP Tutorial
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
When adding sublime3 to compile system php, use the PHP toolbox, cmd php -v is useless
From 1970-01-01 08:00:00
0
0
0
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|