Ok I have a program which stores all the images in a give directory in a array. I need to make sure that the array has no other files like text files or thumb.db. How can I filter out everything except image files? Can this also be use to instead of image to use for folders also?
<?php // This would be the array you got from your "images in the directory" function $files = array("thing.gif", "another.jpg", "somethingelse.jpeg", "shouldnotbehere.txt", "yetanother.png", "thumbs.db", "more.bmp"); $files = array_filter($files, "imageOnly"); echo "<xmp>"; print_r($files); echo "</xmp>"; function imageOnly($input) { return preg_match('/\.(gif|jpe?g|png|bmp)$/', $input); } ?> PHP: For that you would do: $files = array_filter($files, "is_dir"); PHP:
OK, cool, just have one more question. How do I do a case insensitive comparison? Iam trying to sort the array, but the cases of the files change the order.