how do i select only files that contain *.jpg on the file name / extension and ignore anything else. i realized that my code is trying to get anything it can get on the folder, how do i filter it so it only pick up the jpg files
<?php
$folder = "photobooth/photobooth/Michelle_Illona_Alexander/animated/"; //folder tempat gambar disimpan
$handle = opendir($folder);
$i = 1;
while(false !== ($file = readdir($handle) )){
if($file != '.' && $file != '..'){
$file2=str_replace("_mp4.jpg","",$file);
$file3=substr($file,0);
//$filenames= directory(".","jpg");
//foreach ($filenames as $value)
//{
echo '<li>'.
'<a href="photobooth/photobooth/Michelle_Illona_Alexander/animated/'.$file2.'.mp4">
<img src="photobooth/photobooth/Michelle_Illona_Alexander/animated/'.$file.'" width="300" title="" type="jpg"></a>'.
'<br/></li>';
if(($i % 4) == 0){
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
}
$i++;
if($i==0)
break;
//}
}
}
?>