src/Helpers/Arrays.php
public static function dirToArr($path): array
    {
        $result = [];
        $dirContent = scandir($path, null);

        foreach ($dirContent as $key => $value) {
            // Exclude system dots folders
            if (!\in_array($value, ['.', '..'])) {
                if (is_dir($path . DIRECTORY_SEPARATOR . $value)) {
                    $result[$value] = self::dirToArr($path . DIRECTORY_SEPARATOR . $value);
                } else {
                    $result[] = $value;
                }
            }
        }

        return $result;
    }
public static function dirToArr($path): array
    {
        $result = [];
        $dirContent = scandir($path, null);

        foreach ($dirContent as $key => $value) {
            // Exclude system dots folders
            if (!\in_array($value, ['.', '..'])) {
                if (is_dir($path . DIRECTORY_SEPARATOR . $value)) {
                    $result[$value] = self::dirToArr($path . DIRECTORY_SEPARATOR . $value);
                } else {
                    $result[] = $value;
                }
            }
        }

        return $result;
    }
public static function dirToArr ( $ path ) : array { $ result = [ ] ; $ dirContent = scandir ( $ path , null ) ; foreach ( $ dirContent as $ key => $ value ) { // Exclude system dots folders if ( ! \ in_array ( $ value , [ '.' , '..' ] ) ) { if ( is_dir ( $ path . DIRECTORY_SEPARATOR . $ value ) ) { $ result [ $ value ] = self :: dirToArr ( $ path . DIRECTORY_SEPARATOR . $ value ) ; } else { $ result [ ] = $ value ; } } } return $ result ; }
Read any files and folder into some directory

@param   string $path - Source directory with files
@return  array
Read any files and folder into some directory