/* 只列出.ini文件 */
<?php
$str = opendir('./');
while (($filename = readdir($str)) !== false) {
    if ($filename != ".") {
        if (is_file($filename)) {
            if (substr(strrchr($filename, '.'), 1) == "ini") {
                $file_array[] = $filename;
            }
        }
    }
}
closedir($str);
print_r($file_array);
?>
/* 列出所有文件和目录 */
<?php
$str = opendir('./');
while( ($filename = readdir($str)) !== false ) 
{
    if($filename != "." && $filename != "..")
    {
        if (is_file($filename)){
            $file_array[]=$filename;
        }else{
            $dir_array[]=$filename;
        }
    }
}
closedir($str);
print_r($file_array);
print_r($dir_array);
?>
Last modification:April 12, 2022
如果觉得我的文章对你有用,请随意赞赏