PHP: scandir - Manual
<?php
lireArbo('.');
function lireArbo($rep,$lvl="") {
$racine = scandir($rep);
foreach ($racine as $value) {
//on ignore ces deux valeurs
if ($value === '.' || $value === '..') {
continue;
}
$ligne = "$rep/$value";
//on teste si la variable est un fichier
if (is_file($ligne)) {
echo $lvl." ".$value."<br>\n";
continue;
}
//on teste si c'est un dossier
if (is_dir($ligne)) {
echo $lvl."[D] ".$value."<br>\n";
lireArbo($ligne,$lvl."-");
}
}
}
?>
Wed Jul 19 17:00:33 2023 - permalink -
-
https://www.php.net/manual/fr/function.scandir.php