'; foreach($list as $file){ $target = "$dir/$file"; ..."/> '; foreach($list as $file){ $target = "$dir/$file"; ...">
Home > Article > Backend Development > PHP file traversal
$dir = "D:\workspace"; function list_file($dir = '.'){ $list = scandir($dir); echo '<ol>'; foreach($list as $file){ $target = "$dir/$file"; if ( is_dir($target) && $file != '.' && $file != '..' ){ echo "<li style=\"color:red;font-weight:bold;\">$file</li>"; list_file($target); } else if ( $file != '.' && $file != '..'){ echo "<li>$file</li>"; } } echo '</ol>'; } list_file($dir);