如何删除php目录中的点

如何删除php目录中的点,php,Php,我有一个代码显示目录中的点。我正试图摆脱他们,但谷歌没有帮助,这些点意味着返回和本地主机和点需要删除我怎么做呢 <?php $map = opendir('file'); while ($bestand = readdir($map)) { echo "<a href='file/$bestand'>$bestand</a><br/>"; } closedir($map); ?> 添加 if ($bestand == '.

我有一个代码显示目录中的点。我正试图摆脱他们,但谷歌没有帮助,这些点意味着返回和本地主机和点需要删除我怎么做呢

<?php
 $map = opendir('file');
 while ($bestand = readdir($map))
 {
   echo "<a href='file/$bestand'>$bestand</a><br/>"; 
 }
 closedir($map); 
?>

添加

if ($bestand == '.' || $bestand == '..')
    continue;
在线路包含回音之前

只要$bestand是点,此代码将跳过迭代。

添加

if(is_dir($bestand)){ continue; }
在循环中。
这将跳过所有目录,只添加文件。

参考手册,并添加到HungHsuan Wei的答案中

<?php

if ($map = opendir('file')) {

    /* This is the correct way to loop over the directory. */
    while (false !== ($entry = readdir($map))) {
        if($bestand == '.' || $bestand == '..')
        continue;
    }    
    closedir($handle);
}

使用
if!(在数组($bestand,array(“.”,“.”)中)
?@ka_-lin如果它是工作代码,请发布一个答案(加上一些额外的词,说明它的作用以及为什么工作),而不是评论。