Answers for "get all directories php"

PHP
0

scan all directories and files php

<?php
function getDirContents($dir, &$results = array()) {
    $files = scandir($dir);

    foreach ($files as $key => $value) {
        $path = realpath($dir . DIRECTORY_SEPARATOR . $value);
        if (!is_dir($path)) {
            $results[] = $path;
        } else if ($value != "." && $value != "..") {
            getDirContents($path, $results);
            $results[] = $path;
        }
    }

    return $results;
}

var_dump(getDirContents('/xampp/htdocs/WORK'));
Posted by: Guest on November-11-2021
0

php list directories

$dir = '.';
$directories = glob($dir . '/*', GLOB_ONLYDIR);
Posted by: Guest on July-22-2020

Code answers related to "get all directories php"

Browse Popular Code Answers by Language