Forum Moderators: coopster
I have a folder with many images with different names, for example 123_456_789_***_***.bmp
The "123", "456", "789" are values that i get from a database and the "***" can be different characters, that are different for each image.
I want to show these images but i can't find a way to 'search' in the name of the image, in order to find "***" characters and use it.
For example:
echo "<img src='images/".$id1 ."_" .$id2 . "_" . $id3 . "_" .*** . "_" . *** . ".bmp' >";
Is there a way to solve this problem?
Thanks a lot!
function getImages($dir){
$fulldir = $_SERVER['DOCUMENT_ROOT']."/$dir";
$images = array();//if directory is valid
if(is_dir($fulldir)){
$dh = opendir($fulldir);
if($dh){
while(($file = readdir($dh)) != false){if(preg_match( "/[a-zA-Z0-9\_\.\-\s]+\.jpg¦bmp¦gif¦png$/", $file)){
//echo "filename: $file : filetype: " . filetype("$file") . "<br>";
$images[] = array(
"file" => "/$fulldir/$file",
"name" => substr($file, 0, -4),
"type" => substr($file, -3));
}}
}
closedir($dh);
return $images;
}}
$myImages = getImages("images/icons");
I want to save the picture with that name and display it according its id "1_2".
Someone from another forum told me to use glob() and i'm trying this way!
But thank you very much for your interest!