select the first picture from all the pictures present in a directory
<p>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 ?</p>

<pre><code>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 .= '&lt;img src="'.$image.'" /&gt;';
    }

   return $ret;
}
</code></pre>
