Answers for "php loop files in directory"

PHP
0

php iterate folder

// Shows us all files and directories in directory except "." and "..".

foreach (new DirectoryIterator('../moodle') as $fileInfo) {
    if($fileInfo->isDot()) continue;
    echo $fileInfo->getFilename() . "<br>\n";
}
Posted by: Guest on October-07-2020
0

loop through files php

<?php 
	$folder = '/path/'; //directory or folder to loop through
	$checkFiles = scandir($folder); //scan folder content
	$fileCount = count($checkFiles); //count number of files in the directory
	$i = 0; //set for iteration;
	while($i < $fileCount){
    	$file = $checkFiles[$i]; //each file is stored in an array ... 
      	if($file = '.' || $file = '..'){
        	//echo nothing
        }else{
          echo $file; // file names are printed out
        }
    }
?>
Posted by: Guest on June-20-2021

Code answers related to "php loop files in directory"

Browse Popular Code Answers by Language