PHP File Handling Cheat Sheet
Accessing Directory Read Directory Files into Array $dir = ‘example’; $files = scandir($dir, ‘w’) or die(‘Cannot read directory: ‘.$dir); //implicitly creates file foreach ($files as $file) { //do something with $file } Open and Close Directory $dir = ‘example’; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) … Read more