PHP scandir() Function

0

The scandir() function returns an array of files and directories of the specified directory. Required. Specifies the directory to be scanned and follow below example. You may also like How to Copy file from one folder to another folder using PHP and How to get file size in PHP.

Example

<?php
    $dir = "ipafiles/";
    $cdir = scandir($dir);
    echo "<pre>";
    print_r($cdir);
?>

Output

Array
(
    [0] => .
    [1] => ..
    [2] => ifl2ux.ipa
    [3] => iflux.ipa
)

Get data using foreach loop

<?php
   $dir = "ipafiles/";
   $cdir = scandir($dir);
   foreach ($cdir as $key => $value)
   { 
       if (!in_array($value,array(".","..")))
       {  
           echo $value;
       }
   }
?>