簡體   English   中英

打印目錄列表時刪除某些項目

[英]remove certain items when printing a directory list

我正在讓用戶使用打開並讀取目錄的下拉菜單從目錄中選擇特定文件。

在目錄清單中,有些項目不應該存在。

.
..
.com.apple.timemachine.supported
.DS_Store

我將如何刪除這些? 它們看起來像目錄命令或信息之類的東西。 用戶不應該選擇這些,即使我認為他們也不會。

這是我用來讀取目錄並將項目打印到下拉菜單中的代碼。

<div id='fileOpen'>    
<?
    $pathToImages = 'images/';
    $pathToVolume = '/Volumes/storage/spots_in/';

    if ($handle = opendir($pathToVolume)) {
?>
    <span class='locate'>Locate master file:</span>
    <select id='file' name='file'> 
<?
    while (false !== ($entry = readdir($handle))) {
        echo "<option>";
        echo "$entry\n";
        echo "</option>";
    }
    closedir($handle);
 }
</div>

我用這個

if (!preg_match("/^\./","$entry\n"))
while (false !== ($entry = readdir($handle))) {
    if (substr($entry, 0, 1) == '.') {
        continue;
    }

    /* Other stuff
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM