Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
$dir = ''; //put your directory info here
$dh = opendir($dir);
while (false !== ($file = readdir($dh))){
if (!is_dir($file)){echo $file . "<br/>";}
}
if ($handle = opendir($loc)) {
while (false !== ($file = readdir($handle))) {
if (is_dir($loc.$file)) continue;
if ($file != "." && $file != "..") {
$thelist .= "$file";
}
}
}
echo $thelist;
echo "<option value=\"\" selected>----------------------------</option>";
$dir = 'content/';
$handle = opendir($dir);
while(($item = readdir($handle)) !== false) {
if(( $item != '.' ) && ( $item != '..' ) && is_dir($dir.$item)) {
// DISPLAY DIRECTORIES
echo "<option value=\"$item\">$item</option>";
}
}
Now, how do I display all directories, including subdirectories (no files this time smile)?
/* ######## Searchdir ########
What is it: It's a dirlisting script, based on Nicolas Merlet - admin(at)merletn.org example on [URL unfurl="true"]www.php.net,[/URL]
as improved by josh _at_ thenewfood _dot_ com.
It has been slightly modified by Olav Alexander Mjelde
How it works:
It quite simply gathers a dirlist script and returns an array with the dirlisting.
CAUTION: If only path is specified, it crawls unlimited sub-dirs!!
*/
function searchdir ( $path , $maxdepth = -1 , $mode = "FULL" , $d = 0, $exclude = "index.php" )
{
// $path : path to browse
// $maxdepth : how deep to browse (-1=unlimited)
// $mode : "FULL"|"DIRS"|"FILES"
// $d : must not be defined
if ( substr ( $path , strlen ( $path ) - 1 ) != '/' ) { $path .= '/' ; }
$dirlist = array () ;
if ( $mode != "FILES" ) { $dirlist[] = $path ; }
if ( $handle = opendir ( $path ) )
{
while ( false !== ( $file = readdir ( $handle ) ) )
{
if ( $file != '.' && $file != '..' && $file != $exclude)
{
$file = $path . $file ;
if ( ! is_dir ( $file ) ) { if ( $mode != "DIRS" ) { $dirlist[] = $file ; } }
elseif ( $d >=0 && ($d < $maxdepth || $maxdepth < 0) )
{
$result = searchdir ( $file . '/' , $maxdepth , $mode , $d + 1 ) ;
$dirlist = array_merge ( $dirlist , $result ) ;
}
}
}
closedir ( $handle ) ;
}
if ( $d == 0 ) { natcasesort ( $dirlist ) ; }
return ( $dirlist ) ;
}