Home > Backend Development > PHP Tutorial > How to display subdirectories under a specified directory in php_PHP tutorial

How to display subdirectories under a specified directory in php_PHP tutorial

WBOY
Release: 2016-07-13 10:01:11
Original
1277 people have browsed it

How to display subdirectories under a specified directory in php

This article mainly introduces how to display subdirectories under a specified directory in php, involving the skills of operating directories in php, and has certain reference value , friends in need can refer to it

The example in this article describes how to display subdirectories under a specified directory in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

echo "

subdirs in dir

    ";

    $basedir = basename( __FILE__ );

    $dirtoscan = ($basedir . '/somedir/');

    $albumlisting = scandir($dirtoscan);

    foreach ($albumlisting as $item) {

    $dirinfo = pathinfo($item);

    print_r($dirinfo);

    if (is_dir("$item")) {

    echo "

  • $item
  • ";

    }

    }

    ?>

1 2

3

4 5

67 8 9 10 11 12
13
<🎜>echo "

subdirs in dir

    "; $basedir = basename( __FILE__ ); $dirtoscan = ($basedir . '/somedir/'); $albumlisting = scandir($dirtoscan); foreach ($albumlisting as $item) { $dirinfo = pathinfo($item); print_r($dirinfo); if (is_dir("$item")) { echo "
  • $item
  • "; } } ?>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/971954.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/971954.htmlTechArticleHow to display subdirectories under a specified directory in php. This article mainly introduces how to display subdirectories under a specified directory in php, involving The skills of operating directories in PHP have certain reference value. You need...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template