从阅读 php 脚本的子文件夹中删除前两个条目

Remove first two entrys from subfolder reading php script

我得到了一个函数,它从特定目录获取所有子文件夹并在 html 输出中显示子文件夹 php.It 到目前为止工作正常,但现在我有两个来自上面文件夹的条目显示作为 。第二个条目是..我必须如何修改我的脚本?

<?php
$dir = "pictures/whatsapp/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {

// Where to filter or delete the two entrys from folder . and .. ???

            echo '<a href="whatsapp/'.$file.'/" title="Whatsapp DP '.ucwords(str_replace("-"," ", $file)).' Images"><i class="ion-social-whatsapp-outline"></i>'.ucwords(str_replace("-"," ", $file)).'<i class="ion-record"></i></a>';
        }
        closedir($dh);
    }
}
?>

只需添加到循环下面的行即可跳过 om 。和..

if ($file == "." or $file == "..") continue;