The glob() function in PHP allows you to search folders and put the results into an array based on basic filtering.
glob()
- https://www.php.net/manual/en/function.glob.php
- https://www.w3schools.com/php/func_filesystem_glob.asp
glob.php
<?php
$glob = glob("./folder/*");
print_r($glob);
echo "<br><br>";
foreach($glob as $file) {
echo $file."<br>";
}
?>
glob.php (with Image Embed)
<?php
$glob = glob("./folder/*.jpeg");
print_r($glob);
echo "<br><br>";
foreach($glob as $file) {
echo "<img src='".$file."'><br>";
}
?>
Be the first to comment