I'm currently using this
foreach (glob('img/gallery/*') as $dir) {
$folder = str_replace('img/gallery/', '', $dir);
foreach (glob($dir.'/*.jpg') as $img) {
$img1 = str_replace('img/gallery/'.$folder.'/', '', $img);
$img1 = str_replace('.jpg', '', $img1);
$img = str_replace(' ', '%20', $img);?>
<a class="portfolio" title="<?=$img1?>" href="<?=$img?>">
<li class="mix <?=$folder?>"
data-cat="<?=$folder?>"
style="height:145px;width:145px;float:left;margin-right:2.5px;margin-left:2.5px;margin-bottom:5px; background:url(<?=$img?>);background-size:cover;">
</li>
</a>
<? }
}
And it's working fine doing exactly what I need, getting all of the files and folder names and displaying them, the problem is now that i've got:
Warning: Invalid argument supplied for foreach() in index.php on line 188
Displaying in the source code, but it's all working. Line 188 is the second foreach.