Listing Files and Folders with PHP

Sometimes a moment comes when you need to list or read the folders and files inside a directory. Here I am sharing a function you can use in exactly those situations, I hope it is useful :)
Our function is quite simple, and inside it you can keep the files / folders you do not want from being listed. We have also added the directory link, so you can reach them easily.
function dizin_listele($dizin)
{
if(is_dir($dizin))
{
if($durum = opendir($dizin))
{
$say=0;
while(($dosya = readdir($durum)) !== false)
{
if(
$dosya != "." &&
$dosya != ".." &&
$dosya != "Thumbs.db" &&
$dosya != "admin.php" &&
$dosya != "include"
// Here you can enter the name of a file or folder you do not want listed
)
{
$say++;
echo '<a target="_blank" href="'.$dizin.$dosya.'">'.$dosya.'</a><br>'."\n";
}
}
echo '<br />A total of '.$say.' files/folders are shown';
closedir($durum);
}
}
}
dizin_listele("xtbadmin/");
// Let's specify the path of the folder to be listed.
I hope you get to use it in good days.
Take care...