我有一个函数,它从特定的目录中获取所有子文件夹,并使用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);
}
}
?>
答案 0 :(得分:0)
只需添加循环以下行即可跳过om。和..
if ($file == "." or $file == "..") continue;