Files

List Directory/Folder Contents

$path = "MyFolder";
$files = scandir ($path);

foreach ($files as $file) {
      echo $file;
}

Remove . And .. (these dots represent current and parent directories) from Files List
$path = "MyFolder";
$files = scandir ($path);

foreach ($files as $file) {
      if ($file != "." && $file != "..") {
            echo $file;
      }
}

Another way of removing those dots
$path = "MyFolder";
$files = scandir ($path);
$files = array_diff ($files, ['.', '..'] ); // excluding . and .. form the array
foreach ($files as $file) {
      echo $file;
}