[PHP] Read a dir into an Array

I’m having problems reading a directory into an array.

here is what I’m using to get a list of files:


<?php
function ls($path){
	//Define Path
	//$path = "/home/omnifiles/public_html";
	
	$dir_handle = @opendir($path) or die("Unable to open $path");
	//echo "Directory Listing Of $path<br />";
	
	while ($file = readdir($dir_handle)){
		if ($file != "." && $file != ".."){
"<a href='$file'>$file</a> extension: ". showExtension($file) . " filesize: ". fsize($file) ." permissions: " . fileperms($file) . "<br />";
		}
	}
	
	closedir($dir_handle);
}

$file is filled with names of files.

to display them

change this:

"<a href='$file'>$file</a> extension: ". showExtension($file) . " filesize: ". fsize($file) ." permissions: " . fileperms($file) . "<br />";

into this:

echo "<a href='$file'>$file</a> extension: ". showExtension($file) . " filesize: ". fsize($file) ." permissions: " . fileperms($file) . "<br />";

Ok, sorry, when I was editing the code for the forum, I messed it up. I had echo in there, but echo only echoes that 1 file name. I want the whole directory listing to be placed into an array.