从目录中存在的所有图片中选择第一张图片

i made a function in which it prints all the file names with path inside a directory. but i want only first image to be fetched and if there is no image inside the directory print a custom path with a image . any help on this ?

function getphotos($album_name)
{
    //path to directory to scan
    $dir = ROOTPATH . "/data/img/gallery/$album_name/";

    //get all files
    $images = glob($dir . "{*.jpg,*.gif,*.jpeg}", GLOB_BRACE);

$ret = "";

    foreach($images as $image)
    {
        $ret .= '<img src="'.$image.'" />';
    }

   return $ret;
}
$ret = '<img src="' . (empty($images) ? DEFAULTIMG : $images[0]) . '/>';