Hi
My PHP “expertise” does not go much beyond “copy and paste”.
What syntax do I need to replace = images/intro/ with $img2_folder see below
I have this variable name & value
$img2_folder = “images/intro/”;
The code at the bottom of this post correctly displays all images from folder images/intro/ that meet my criteria, in filename order.
I have managed to include my variable $img2_folder in the echo (last line) but all attempts to replace images/intro/ with $img2_folder in the line starting $handle either do not work or break the page.
I have tried multiple syntax variations eg (FILE))./’.$img2_folder.’);
I think the main issue is something to do with how to include the necessary / and $img2_folder
<?php
$Count1image2 = 0;
$image2;
$handle = opendir(dirname(realpath(__FILE__)).'/images/intro/');
while($file = readdir($handle)){
if($file !== '.' && $file !== '..' && ( strpos($file,"damage") !== false && strpos($file,"$city") !== false )){
$image2[$Count1image2] = $file;
$Count1image2++;
}
}
sort($image2);
for($i=0; $i<$Count1image2; $i++)
echo '<amp-img src="'.$img2_folder.$image2[$i].'" alt="'.$img2_alt.'" class="xs-12" width="353" height="210" layout="responsive"></amp-img>';
//original echo '<amp-img src="images/intro/'.$image2[$i].'"
?>