i have a big question about this trick, i have this script where is going in folder and taking all images from folders and sub folders, what i want is to display Title of parent of each folder so bassically if in my foreach is displaying from a folder 3 images and folder name is House 301 to have above the name of folder and under all 3 images and so on... because i have a structure like this ParentFolder>House 301, House 302, House 303, and in each folder have images. Here is my php:
<?php
function recursiveGlob($pattern)
{
$subPatterns = explode('/**/', $pattern);
// Get sub dirs
$dirs = glob(array_shift($subPatterns) . '/*', GLOB_ONLYDIR);
// Get files in the current dir
$files = glob($pattern);
foreach ($dirs as $dir) {
$subDirList = recursiveGlob($dir . '/**/' . implode('/**/', $subPatterns));
$files = array_merge($files, $subDirList);
}
return $files;
}?>
<?php
$oras = $row['name'];
$files = recursiveGlob("wp-content/themes/xxx/poze_lucrari/".$oras."/**/*.jpg");
echo '<div class="imagini">';
for ($i=0; $i<count($files); $i++)
{
echo '<div class="grid">';
if(isset($files[$i])){
$num = $files[$i];
echo '<div class="grid-item"><a data-lightbox="example-set" href="https://www.xxx.ro/'.$num.'" data-title="Incalzire Electrica in pardoseala '.$oras.'"><img class="img-res" src="https://www.xxx.ro/'.$num.'" alt="Incalzire Electrica in pardoseala '.$oras.'" /></a></div>';
echo $root;
$num1 = str_replace($root.'Images/', '', $num);
if (strpos($num1,'.png') == true)
{
$text = str_replace('.png', '', $num1);
}
if (strpos($num1,'.jpeg') == true)
{
$text = str_replace('.jpeg', '', $num1);
}
if (strpos($num1,'.jpg') == true)
{
$text = str_replace('.jpg', '', $num1);
}
if (strpos($num1,'.tiff') == true)
{
$text = str_replace('.tiff', '', $num1);
}
if (strpos($num1,'.gif') == true)
{
$text = str_replace('.gif', '', $num1);
}
}
echo '</div>';
}
echo '</div>';
?>
I have multiple folders with cities and inside of each city i have anothers folders which they have inside images, i want automatically to enter on all city folder and display Name of folder and under images what have inside of him and next...etc for every folder.