日期:2014-05-17 浏览次数:20493 次
<?php
$handle=opendir("./");
while(false!==($file=readdir($handle))){
if ($file != "." && $file != ".."){
echo "$file<br>";
}
}
closedir($handle);
?>
public function listDir($path, $size=false, $toCsv=false)
{
if (false !== $toCsv) $newCsv = new SplFileObject($toCsv, 'wb');
$items = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
$arr = array();
while (list($itemName, $item) = each($items))
//foreach($dir as $itemName => $item)
{
$fileInfo = array();
$fileInfo['fullpath'] = (string)$itemName;
if ($size) $fileInfo['size'] = (string)$item->getSize();
if (false !== $toCsv) $newCsv->fputcsv($fileInfo);
$arr[] = $fileInfo;
}
return $arr;
}
function show($dir)
{
echo "<b>{$dir}</b><br/>";
$dir = realpath($dir) .'/*';
foreach(glob($dir, GLOB_MARK) as $f){
if( substr($f, -5) === '.html' ){
$f = "<span style='color:red;'>{$f}</span>";
}
echo $f ."<br/>".PHP_EOL;
if(is_dir($f)){
&