<?php
$dir = "a/";if (is_dir($dir)) 
{
if ($dh = opendir($dir))
{    while (($file = readdir($dh)) !== false)
       {
           echo "$file"."<br>";
          }
          closedir($dh);
}
}
?>这样会输入
.
..
1.jpg
2.jpg
3.jpg
我不想要
.
..
怎么把他去掉!

解决方案 »

  1.   

    <?php
    $dir = "a/";
     
    if (is_dir($dir)) {
        if ($dh = opendir($dir)){
            while (($file = readdir($dh)) !== false){
                if($file=='.'||$file=='..'){continue;}
                echo "$file"."<br>";
            }
            closedir($dh);
        }
    }
    ?>
      

  2.   

    $dir = "a/";
    echo join('<br>', glob("$dir*.*"));
      

  3.   

    $dir = "a/";
    //只取文件名
    echo join('<br>', array_map('basename',array_filter(glob("$dir*"), 'is_file')));