scandir无法正常运行php
问题描述:
Does any one know how to scan directory recursively in php ?
$fileslist = array();
function readRecursive($dirname) {
global $fileslist;
$dir = scandir($dirname);
foreach ($dir as $f) {
if($f != "." && $f != ".." && $f != ".DS_Store") {
if(is_dir($dirname.DIRECTORY_SEPARATOR.$f)) {
$dname = $dirname.DIRECTORY_SEPARATOR.$f;
readRecursive($dname);
} else {
$fileslist[] = $dirname.DIRECTORY_SEPARATOR.$f;
}
}
}
}
following code doesn't work any idea Thanks in advance
有没有人知道如何在php中递归扫描目录? p>
$ fileslist = array(); function readRecursive($ dirname){ global $ fileslist; $ dir = scandir($ dirname); foreach($ dir as $ f){\ n if($ f!=“。”&& $ f!=“..”&& $ f!=“。DS_Store”){ if(is_dir($ dirname.DIRECTORY_SEPARATOR。$ f) ){ $ dname = $ dirname.DIRECTORY_SEPARATOR。$ f; readRecursive($ dname); } else { $ fileslist [] = $ dirname.DIRECTORY_SEPARATOR。$ f; } } \ n} } code> pre>以下代码不起作用 提前谢谢 p> div>
答
First check it your php version. this function is available only above php 5.0