I have a bit of PHP code that pulls images from a directory and displays them as
If you check my code below you will that the list ID's are incrementing properly but the variable $i is being echoed as text along with the images. I am trying to get the ID's to increment but I do not want the variable to be echoed. I know the answer is staring me in the face but for the life of me I can't see it being a bit of a PHP novice.
PHP CODE
<?php
$files = glob("images/assets/*.{png,jpg,jpeg}", GLOB_BRACE);
$i = 1;
foreach ($files as $file)
echo "<li id:\"S-$i\"><img class=\"zuper\" src=\"$file\" /></li>",
$i++;
?>
Generated HTML
<li id:"S-1"><img class="zuper" src="images/assets/1.jpg" /></li>1
<li id:"S-2"><img class="zuper" src="images/assets/2.jpg" /></li>2
<li id:"S-3"><img class="zuper" src="images/assets/3.jpg" /></li>3
<li id:"S-4"><img class="zuper" src="images/assets/4.jpg" /></li>4
<li id:"S-5"><img class="zuper" src="images/assets/5.jpg" /></li>5
<li id:"S-6"><img class="zuper" src="images/assets/bistro.jpg" /></li>6
<li id:"S-7"><img class="zuper" src="images/assets/hotel.jpg" /></li>7
<li id:"S-8"><img class="zuper" src="images/assets/view.jpg" /></li>8
<li id:"S-9"><img class="zuper" src="images/assets/weddings.jpg" /></li>9
You can see in the generated HTML that the variable $i is being echoed after each
;sign. You have written a,which makes it echo the $i++