php遍歷windows下中文目錄下的所有檔名

2021-09-23 04:17:53 字數 449 閱讀 6205

有時需要遍歷windows下中文目錄下的所有的檔名,使用utf-8編碼的檔案有時會出現亂碼,並且不能成功的執行,

這時需要對檔案的編碼進行一下轉換,使用scandir這個函式的時候會連同目錄一下列出來,大家可以通過is_dir()這個函式來

做乙個判斷,我使用目錄下所的檔案都有擴充套件所以只做了乙個簡單的判斷

**如下 

<?

$dir ="e:\\phpnow-1.5.6\\htdocs_96\\目錄檔案\\";

$dir=iconv("utf-8","gb2312//ignore",$dir);

$files1 = scandir($dir);

foreach($files1 as $v)

if (!is_dir($v) && strpos($v,".")!=false )

?>

Windows下Git Bash中文亂碼

文章 開啟git bash 進入目錄 cd etc 檔案中增加內容 xml gui encoding utf 8 庫統一使用utf 8 i18n commitencoding gb2312 log編碼,window下預設gb2312,宣告後發到伺服器才不會亂碼 svn pathnameencodin...

windows下git bash顯示中文

即git安裝路徑 1 c program files git etc git completion.bash 直接新增 alias ls ls show control chars color auto 說明 使得在 git bash 中輸入 ls 命令,可以正常顯示中文檔名。2 c program...

Windows下Git Bash中文亂碼

開啟git bash 進入目錄 cd etc 1.編輯 gitconfig 檔案 vi gitconfig 檔案中增加內容 gui encoding utf 8 庫統一使用utf 8 i18n commitencoding gb2312 log編碼,window下預設gb2312,宣告後發到伺服器才...