I have an array that was populated by this script :
var imgs = document.getElementsByTagName("img");
var imgSrcs = [];
for (var i = 0; i < imgs.length; i++) {
imgSrcs.push(imgs[i].src);
}
When I echo this out from a PHP, it gives me all the img src with commas separating them. It seems like its not like a typical array format, more like just text. When I tried to do this:
for ($i = 0; $i < count($img); ++$i) {
echo "<img src='".$img."'/><br>";
}
It just echo's one <img src with every single image src that is in imgSrcs.
I'm trying to echo img src and 1 img link. This way if I have 5 links in imgSrcs, i'll output 5 images.
Thanks in advance!
"img="+imgSrcsyou're trying to concatenate your array onto a string, which does a.toString()onimgSrcsresulting in a comma-separated string of the values from the array. Similarly,alert()is used to display strings, soalert(imgSrcs)displays your data with commas because it does a.toString()on your array.