You can use regular expression to match if file name ends with .jpg
or .png
for($index=0; $index < $indexCount; $index++)
{
if(preg_match("/^.*\.(jpg|png)$/i", $dirArray[$index]) == 1)
{
echo "<option value=\"".$dirArray[$index]."\">".$dirArray[$index]."</option>";
}
}
/i
at the end of regular expression is case insensitive flag.