Home  >  Article  >  Backend Development  >  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
WBOYOriginal
2016-07-13 10:01:111264browse

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...
Statement:
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