Search
 
SCRIPT & CODE EXAMPLE
 

PHP

recursive directory only listing php

function recursive_directory($dirname, $maxdepth = 10, $depth = 0)
{
    if ($depth >= $maxdepth) {
        return false;
    }
    $subdirectories = array();
    $files = array();
    
    if (is_dir($dirname) && is_readable($dirname)) {
        $d = dir($dirname);
        while (false !== ($f = $d->read())) {
            $file = $d->path . '/' . $f;
            // skip . and ..
            if (('.' == $f) || ('..' == $f)) {
                continue;
            }
            if (is_dir($dirname . '/' . $f)) {
                array_push($subdirectories, $dirname . '/' . $f);
                array_push($files, $dirname . '/' . $f); // list dir
            } else {
                //array_push($files, $dirname . '/' . $f); list files
            };
        }
        $d->close();
        foreach ($subdirectories as $subdirectory) {
            $files = array_merge($files, recursive_directory($subdirectory, $maxdepth, $depth + 1));
        }
    }
    return $files;
}
Comment

PREVIOUS NEXT
Code Example
Php :: php version not update after windows env file 
Php :: what is carriage return in php 
Php :: laravel combo unique validation 
Php :: add class to row laravel 
Php :: how to fetch days old records php mysql 
Php :: Invalid datetime format: 1366 Incorrect string value 
Php :: yii2 active data provider 
Php :: status code 301 
Php :: php initialize two dimensional array dynamically 
Php :: @admin @endadmin 
Php :: Laravel htaccess for aws ec2 
Php :: laravel eloquent with nested 
Php :: smtp_port" setting in php.ini or use ini_set() 
Php :: In QueryRecorder.php line 22: Argument 2 passed to FacadeIgnitionQueryRecorderQueryRecorder::__construct() must be of the type bool, null given, 
Php :: readable date in php 
Php :: php heredoc function 
Php :: financial year calculation in php 
Php :: how to enable autoreload on save 
Php :: how to fetch associate data from csv in php 
Php :: PHP Iterables 
Php :: run queue after x minutes laravel 
Php :: how to set 1 year date without saturday in while loop php 
Php :: Update Data Multiple Columns MySql Database Table PHP Function 
Php :: update to php 7.4 
Php :: php unset by value 
Php :: array_filter in php 
Php :: echo require php 
Php :: Laravel 7 pagination with search filter 
Php :: how to know who added product in magento 
Php :: laravel enable query log 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =