Multilevel Array

Right now I have a script that grabs all the files in a directory and pushes it into an array called $files. The script then echos out each object in that array first outputing the file name in the first column of a table then the file size “filesize($file)” then the date the file was added to the server.

My main issue is I want to be able to sort the table data either by file name, size or date. To do this i’m wondering if i should use a multilevel array. And “array_multisort()”.

My main question is how do I push the info into a multilevel array?


$dir = getcwd();

// Create $files array and populate with files from $dir
$files = array();
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if($file != ((substr("$file",4)) != (".jpg" || “.png” || “.bmp”)))
if($file != “index.php”)
if($file != “localactions.php”){
array_push($files, $file);



Sponsor our Newsletter | Privacy Policy | Terms of Service