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
Group MySQL results by ID for looping over
I have a table with flight data in mysql. I'm writing a php code that will group and displ...
From 2024-04-06 17:27:56
0
1
406
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|