php 之 opendir readdir 顯示資料夾,裡面的檔案

php opendir readdir 使用 範例 顯示目錄內所有檔案

想要找個php代碼,用來顯示目錄內所有檔案,含目錄內的目錄下的檔案,

https://www.php.net/manual/zh/function.opendir.php

線上中文手冊查了一下opendir的用法,找到一串代碼,如下




避免被瀏覽器解析掉,請下載【 sample002.zip 】範例檔,打開檢視


drive.googleskydriveasuswebstoragesync.hamicloud.net


但我要的是所有目錄及檔案個別位置,於是改成如下




結果




全連在一起,但只要右鍵,檢視源始碼,就可整齊顯示







在來就是限制只抓文字檔類的副檔名如:txt、htm等,參考下圖




代碼請參考下貼,zip解壓後打開index.php就可以看見


php 簡 轉 繁 轉 UTF8 工具


Thank you for reading

沒有留言:

發佈留言

由於一直被灌水, 因此您發表留言之後, 需要等待博客主的審核, 才會公開您的留言, 所以請不要重複的留言
Hello my friend, I have no money, My blog is super chill, Please do not screw me up in the replies at the bottom of the article, thanks a lot