function getfiles($path)
{
foreach(scandir($path) as $afile)
{
if($afile=='.'|| $afile=='..') continue;
if(is_dir($path.'/'.$afile))
{
getfiles($path.'/'.$afile);
} else {
echo $path.'/'.$afile.'</br>';
}
}
}
getfiles('\images');如何上,如何把echo的值以数组形式在函数中返回?谢谢
{
foreach(scandir($path) as $afile)
{
if($afile=='.'|| $afile=='..') continue;
if(is_dir($path.'/'.$afile))
{
getfiles($path.'/'.$afile);
} else {
echo $path.'/'.$afile.'</br>';
}
}
}
getfiles('\images');如何上,如何把echo的值以数组形式在函数中返回?谢谢
{
$res = array();
foreach(scandir($path) as $afile)
{
if($afile=='.'|| $afile=='..') continue;
if(is_dir($path.'/'.$afile))
{
$res = array_merge($res, getfiles($path.'/'.$afile));
} else {
$res[] = $path.'/'.$afile;
}
}
return $res;
} $d = getfiles('images');
http://blog.csdn.net/fdipzone/article/details/8704191
echo $path.'/'.$afile.'</br>';
改为
$ret[] = $path.'/'.$afile;
就可保存到数组了