Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

PHP glob() Function

The glob() function can be used to get an array which lists files from a chosen directory. For example, the command below will return an array of the image names from the images/gallery folder.

$files = glob(“images/gallery/*.*”);

The code below shows how to use glob() function to get an array of filnames for images for which a for loop is used to create thumnails and images links for each image.

$files = glob("images/gallery/*.*");

for ($i=0; $i<count($files); $i++)
{
    $num = $files[$i];
    /*print "<a href='".$SERVER[PHP_SELF]."?myeditor=".$num."'>".$num."</a><br />";
    echo '<img src="'.$num.'" alt="random image" />'."<br /><br />";*/
    
    echo '<div class="image_align">
                            <div class="myimage"><a href="'.$num.'" rel="shadowbox"><img alt="placeholder" height="98" src="'.$num.'" width="130"> </a></div>
                        </div>';
}