Jump to content

function to show message if no file found?


jacko310592

Recommended Posts

hey guys

 

below is my code which uses the glob function to grab image file names and place them into a combo-box...

 

<?php
  $files = glob("{*.JPG,*.jpg}", GLOB_BRACE);
    for ($i=0; $i<count($files); $i++)
      {
        $photoId = $files[$i];
        $photoId = substr($photoId,0,-4);  //used to remove file ext

if (stristr($photoId, "[")===FALSE)  //'[' is written within images filenames to mark images i dont want the code to output.
        echo '
			<option value="'.$photoId.'">'.$photoId.'</option>
			';
}
?>

 

can anyone think of a way in which this code can be althered to show an <option>no images found</option> if no files can be found within the directory/no files without the '[' can be found

 

 

 

 

thanks guys

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.