Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dev-hpjsolutions/6022153 to your computer and use it in GitHub Desktop.
Save dev-hpjsolutions/6022153 to your computer and use it in GitHub Desktop.
obtenir la première image d'un répertoire
function get_nom_image($dirname){
$ext = array("jpg", "png", "jpeg", "gif", "JPG", "PNG", "GIF", "JPEG");
$imageName='';
if($handle = opendir($dirname))
{
while(false!== ($file = readdir($handle)))
{
if(strstr($file, "." . $ext[$i])!= '.' && strstr($file, "." . $ext[$i])!= '..')
{
break;
}
}
$imageName = $file;
closedir($handle);
}
return($imageName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment