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

问题描述 投票:0回答:1

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

<?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);
    }
}
?>
php directory subdirectory
1个回答
0
投票

只需添加循环跟随行即可跳过om。和..

if ($file == "." or $file == "..") continue;
© www.soinside.com 2019 - 2024. All rights reserved.