0) OR (strpos($file, '.jpg')>0)){ $image[$count] = array ($file); $count++; } } shuffle($image); shuffle($image); shuffle($image); closedir($dirHandle); //$arrays2 = count($image) -1; //echo "\n"; $arrays = 28; $loop = 0; while ($loop < $arrays) { $string = $image[$loop][0]; $Rstring = strrev($string); $ProdID = strrev(substr_replace($Rstring,'',0,4)); $ImgHTML = 'Product # '.$ProdID.'  '; echo $ImgHTML; $loop++; } ?>