1
我有一段代碼,我正在使用,它工作正常,唯一的問題是當文件夾或文件名稱中有一個空間,它只鏈接(或顯示器)在文件名中opendir不起作用的文件或文件夾名稱間隔
請幫助的第一個字,
感謝
<?php
$dirFiles = array();
// opens images folder
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
// strips files extensions
$crap = array(".jpg", ".jpeg", ".JPG", ".JPEG", ".png", ".PNG", ".gif", ".GIF", ".bmp", ".BMP", "_", "-", "error_log", ".php");
$newstring = str_replace($crap, " ", $file);
//asort($file, SORT_NUMERIC); - doesnt work :(
// hides folders, writes out ul of images and thumbnails from two folders
if ($file != "." && $file != ".." && $file != "index.php" && $file != "Thumbnails") {
$dirFiles[] = $file;
}
}
closedir($handle);
}
sort($dirFiles);
foreach($dirFiles as $file)
{
echo "<li>";
echo "<a href=".$file.">".$file."<br></li>";
}
?>