Php : How To Use Scandir To Show Files Names

Php Code : How To Show Filenames Using Scandir

________________________________________________________


In this Php Tutorial we will Learn How To Use Scandir To Display Files Names From Folder Using Php .

I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .



 




Php Source Code:

<?php

$dir_path = "folder/";
if(is_dir($dir_path))
{
    $files = scandir($dir_path);
    print_r($files);
    echo"<br>";
    for($i = 0; $i < count($files); $i++)
    {
        if($files[$i] != '.' && $files[$i] != '..')
        {
            echo "File $i -> $files[$i]<br>";
        }
    }
}




                     
php using scandir




Share this

Related Posts

Previous
Next Post »

1 comments:

comments
24 novembre 2023 à 13:41 delete

"." - current directory
".." - parent directory

What is the practical use of these dots? What happens when you remove them?

Reply
avatar