如何从具有特定文件名的数组中删除所有图像

I am using the code below to create an array of images. I'd love to be able to not add any images with -c.jpg in the filename. How can I do this?

<?php
$jsarray = array();
$iterator = new DirectoryIterator(dirname("public/images/portfolio/all/"));
foreach ($iterator as $fileinfo) {
    if ($fileinfo->isFile()) {
        //filtering to exclude the color images
        $jsarray[] = "'" . $fileinfo->getFilename() . "'";
    }
}
$jsstring = implode(",", $jsarray);
?>

I'm using PHP5.

$jsarray = array();
$iterator = new DirectoryIterator(dirname("public/images/portfolio/all/"));

foreach ($iterator as $fileinfo) {
    if ($fileinfo->isFile() && !preg_match('/-c\.jpg$/', $fileinfo->getFilename())) {
        $jsarray[] = "'" . $fileinfo->getFilename() . "'";
    }
}

$jsstring = implode(",", $jsarray);

That’s it.

if(strpos($fileinfo->getFilename(), "-c.jpg") === false) {
    $jsarray[] = "'" . $fileinfo->getFilename() . "'";
}

Try that. strpos tells you the position of the search string if it's there, and false if it isn't.