Closed Thread Icon

Topic awaiting preservation: listing files in directory - PHP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30529" title="Pages that link to Topic awaiting preservation: listing files in directory - PHP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: listing files in directory - PHP <span class="small">(Page 1 of 1)</span>\

 
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 09-06-2008 20:31

I have this snippet of code working so far but need something else :

code:
if ($handle = opendir($dir)) { 
			$filecount = "0";
				while (false !== ($file = readdir($handle))) {
					if ($file != "." && $file != "..") { 
						$file = strtolower($file); 
						$fileList[] = trim($file); 
						$filecount = $filecount + 1;
					}
				}
				print 'File Count: <b>'.$filecount.'</b><br>'; 
				
				sort ($fileList);
				reset ($fileList);
				
				
				while (list ($key, $val) = each ($fileList)) {
					echo $val.'<br>';
				}
			closedir($handle);
		}



This works fine in counting the number of pages in a directory as well as listing them. However, I need it to instead of listing the number of files, say "8", I need it to do : 1 2 3 4 5 6 7 8. Or if there are 4 files in that directory, I need it to do : 1 2 3 4.

Hope that makes sense and thanks in advance!!

Later,

C:\

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 09-06-2008 20:58

eigh...I got it. It's the $key in the while loop that I needed

Later,

C:\

« BackwardsOnwards »

Show Forum Drop Down Menu