Search code examples
phpscandir

scandir() returning only "Array"


I'm new with PHP so, I'm getting a problem.

I want to list files as well as directories from a specific directory users.

I'm using this code:

<?php
   $dir = "users/";
   $fl = scandir($dir);
   echo $fl;
?>

which is return only Array, even if the directory have files.

My PHP version is 5.3.5


Solution

  • Just do in this way..

    <?php
       $dir = "users/";
       $fl = scandir($dir);
       foreach (scandir($dir) as $fl)
       echo $fl."<br>";
    ?>
    

    Output like:

    .
    ..
    abc.txt