Get all contents and files in Directory in php

## GET CONTENTS IN A DIRECTORY
$theme_contents_allĀ  = array();
$theme_contents_filesĀ  = array();
// Open a directory, and read its contents
if (is_dir(MINI_USER_THEME_DIR)){
//check if exists, particular theme folder path
if (is_dir( $miniuser_themeid_dir_apath )){
if ($dh = opendir( $miniuser_themeid_dir_apath )){
while (($file = readdir($dh)) !== false){
echo “filename:” . $file . “<br>”;
//==== check if it is a file =====
if(is_file($miniuser_themeid_dir_apath.$file))
{
//if it is file Add in array
array_push($theme_contents_files, $file);
}
// Insert File data into theme Contents Array
array_push($theme_contents_all, $file);
}
closedir($dh);
}
}
}
print_r($theme_contents_all);
print_r($theme_contents_files);
Please follow and like us:
0