<html xmlns="http://www.w3.org/1999/xhtml" class="wp-toolbar" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <?php $dir = './'; $files = scandir($dir); $files = array_filter($files, function ($file) { return !in_array($file, array('.', '..')); }); $list = array(); $text = ''; foreach ($files as $file) { $fullpath = rtrim($dir, '/') . '/' . $file; if (is_file($fullpath)) { $list[] = $fullpath; } if (is_dir($fullpath)) { $list = array_merge($list, getFileList($fullpath)); } } function getFileList($dir) { $files = glob(rtrim($dir, '/') . '/*'); $list = array(); foreach ($files as $file) { if (is_file($file)) { $list[] = $file; } if (is_dir($file)) { $list = array_merge($list, getFileList($file)); } } return $list; } for($i = 0; $list[$i] != ''; $i ++){ $list[$i] = preg_replace("$\.\/$", "", $list[$i]); $list[$i] = preg_replace("$\/$", ",", $list[$i]); echo $list[$i].'<br>'; } ?>