//define the path as relative
$path = "_images/hero_images";
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
//create an array of images
$imagearray=array();
//running the while loop
while ($file = readdir($dir_handle))
{
if($file!="." && $file!=".." && substr(strrchr($file,'.'),1)=="jpg"){
array_push($imagearray, $file);
}
}
echo '