親フォルダ タブ
01.<?php
02.session_cache_limiter('nocache');
03.session_start();
04. 
05.header( "Content-Type: text/html; charset=utf-8" );
06.?>
07.<!DOCTYPE html>
08.<html lang="ja">
09.<head>
10.<meta content="width=device-width initial-scale=1.0 minimum-scale=1.0 maximum-scale=1.0 user-scalable=no" name="viewport">
11.<meta charset="utf-8">
12.<title>list3.php</title>
13.<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
14.<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css">
15.</head>
16.<body>
17.<ul>
18.<?php recursionFiles( realpath("./") ) ?>
19.</ul>
20.</body>
21.</html>
22.<?php
23. 
24.// ***********************************************
25.// 再帰によるファイル一覧作成
26.// ***********************************************
27.function recursionFiles( $target ) {
28. 
29.    // パターンにマッチするパス名を探す
30.    $files = glob( "{$target}/*" );
31. 
32.    foreach ( $files as $file ) {
33.        // ファイル
34.        if (is_file($file)) {
35.            $path_parts = pathinfo($file);
36.            if ( $path_parts['extension'] == "doc" || $path_parts['extension'] == "line" || $path_parts['extension'] == "ttl" ) {
37.                continue;
38.            }
39.            if ( $path_parts['extension'] == "png" || $path_parts['extension'] == "jpg" ) {
40.                continue;
41.            }
42. 
43.            $url = str_replace("/home/lightbox/www/homepage", "", $path_parts['dirname']);
44. 
45.            // 配列に追加
46.            print "<li><a href=\"{$url}/?src={$path_parts['basename']}\">{$path_parts['basename']}</a></li>";
47.        }
48.        // フォルダ
49.        else {
50.            $url = str_replace("/home/lightbox/www/homepage", "", $file);
51.            $path_parts = pathinfo($url);
52.            if ( $path_parts['basename'] == "image" ) {
53.                continue;
54.            }
55. 
56.            print "<li><a href=\"{$url}\">{$path_parts['basename']}</a></li>";
57.            print "<UL>";
58.            // 再帰でさらにフォルダ内を探索する
59.            recursionFiles($file);
60.            print "</UL>";
61.        }
62.    }
63.}
64. 
65. 
66. 
67.?>