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
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
";
}
}
?>
|
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...