如何获取包含子字符串的所有文件

Can somebody help me? I have many pictures with current name like : "black_abc","black_bcd","black_cde","white_abc". How can I get only file with filename contains "Black"?

strpos($filename, 'black') !== false

Something like this [Make use of stripos() [Case-Insensitive]

<?php
$files=array("black_1","white_2","black_3");

for($i=0;$i<count($files);$i++)
{
if(stripos($files[i],'black'))
{
    echo "Filename is $files[$i]";
}
} 

glob will help you find all files containing "Black" in their filename:

$folder = "images";    //the folder containing all your images
$pattern = "*Black*";  //the word you are looking for

$files = glob($folder. '/' . $pattern, GLOB_BRACE);
foreach($files as $filename) {
  //Display all pictures
  echo "<img src='"$folder . "/" . $filename . "' />";
}