I am trying to get the file name populated from this foreach loop into the "####" parts of the code. I know you can do basename() to get a file name but can't see a way for that to work. Is there a way to get the image filename gerenated from $image
and populate it within the "####" parts?
E.g. &image
generates img/test_image.png
, then I want to get the test_image
filename within the "####"
$actual_link = "https://$_SERVER[HTTPS_HOST]$_SERVER[REQUEST_URI]";
$dirname = "saturday/";
$images = glob($dirname."*.jpg");
$cols = 2;
for( $i = 0; $i < count($images) && $image = $images[$i]; $i++) {
if( $i%$cols == 0 ) { echo '<div class="row">'; }
echo '<div class="col-sm-' . 12/$cols . '">';
echo '<img class="lazy store-img" src="img/blank.png" data-src="' . $image . '" alt="" title="" width="1000" height="667">';
echo '<h3>####</h3>';
echo '<button href="#" class="snipcart-add-item btn btn-primary" data-item-id="####" data-item-name="####" data-item-url="' .$actual_link. '" data-item-image="' . $image . '" ' .$price1. '</button>';
echo '</div>';
if( $i%$cols == $cols-1 ) { echo '</div>'; }
}
if( count( $images )%$cols > 0 ) {
echo '</div>';
}