过滤DirectoryIterator输出中的文件

I'm working on a script that gets file modified times, and takes an optional arg that if filled has an array with a list of files to check rather then every file. How could I go about just getting the data for those files in a script like this:

$filesObject = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));

foreach ($filesObject as $key => $object)
{
    $checkFile = filemtime($object->getPathname());
    $num++;
    $alertFiles[$num] = array('name' => $object->getPathname(),
                              'time' => $checkFile);
}

edit: this code is in a function where $filesArray is the array of file names that can be passed.

You can wrap your Iterator in a custom Filter Iterator (to foster reuse)

class FileFilter extends FilterIterator
{
    protected $_files;

    public function __construct($iterator, array $files)
    {
        $this->_files = $files;
        parent::__construct($iterator);
    }

    public function accept()
    {
         return !in_array($this->current(), $this->_files);
    }
}

If accept returns FALSE the current element is not considered in the iteration. Since you give very little information about your $filesArray contents, you might have to change the accept logic to make it work for your code.