I have this function to get items from directory:
if ($dh = opendir($dir)) {
$images = array();
while (($file = readdir($dh)) !== false) {
if (!is_dir($dir.$file)) {
$images[] = $file;
}
}
closedir($dh);
}
return $images;
The function is working, and I am getting this result (this is a test directory):
array (size=9)
0 => string 'odluka o matinim podrujima.shs' (length=31)
1 => string 'Odluka o optinskoj upravi.doc' (length=29)
2 => string 'o_pirotu3.jpg' (length=13)
3 => string 'o_pirotu4.jpg' (length=13)
4 => string 'Panorama 10.jpg' (length=15)
5 => string 'Panorama 8n.jpg' (length=15)
6 => string 'Panorama n.jpg' (length=14)
7 => string 'PRAVILNIK O ORGANIZACIJI I SISTEMATIZACIJI POSLOVA.doc' (length=54)
8 => string 'Pravilnik_o_reprezentaciji.doc' (length=30)
How can I remove all non images items, and is there some way for me to choose mime type that will stay in returned array (I need jpg, png, and bmp)?