F
F
fokin_nikolay19892022-02-11 10:50:37
linux
fokin_nikolay1989, 2022-02-11 10:50:37

How to display directory contents recursively in php?

help to configure the display of the contents of the directory

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Пример веб-страницы с php кодом</title>
</head>
<body>
<?
$dir = "/var/ftp/";
    if($handle = opendir($dir)){
        while(false !== ($file = readdir($handle))) {
            if($file != "." && $file != ".."){
            echo $file."<br>";
        }
    }
}
?>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey delphinpro, 2022-02-11
@delphinpro

https://yandex.ru/search/?clid=1882628&text=php+di...

T
Talyan, 2022-02-11
@flapflapjack

<?
function ftp_recursive($dir)
{

    if($handle = opendir($dir)){
        while(false !== ($file = readdir($handle))) {
            if($file != "." && $file != ".."){
            echo $file."<br>";
            if(is_dir($dir."/".$file)) {ftp_recursive($dir."/".$file);}
        }
    }
}
}
?>


ftp_recursive("/var/ftp/");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question