How can I exclude directories using RecursiveDirectoryIterator
问题 I have the function below. Which goes through directories and recursively searches through them to grab a random image file and then attaches that to a post. What I want to do is exclude some files from the search. I have a comma separated list which I explode into an array, I tried using a filter but couldn't get this to work. Current function without filter is function swmc_get_imgs($start_dir, $ext, $exclude=array()){ $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(