Skip to main content
added 19 characters in body
Source Link
Alsciende
  • 27k
  • 9
  • 54
  • 68
var photos = []; var imgs = document.getElementById("photos").getElementsByTagName("img"); for(var i=0;i<imgs.length;i++){ photos.push({ src:imgs[i].src, alt:imgs[i].alt, background:imgs[i].style.backgroundColor }); } 

That should give you something that is roughly equivalent to this in PHP (I made up pretend data):

Array( [0] => Array( "src" => "logo.png", "alt" => "My Logo!", "background" => "#ffffff" ) ) 

I hope this helps!

var photos = []; var imgs = document.getElementById("photos").getElementsByTagName("img"); for(var i=0;i<imgs.length;i++){ photos.push({src:imgs[i].src,alt:imgs[i].alt,background:imgs[i].style.backgroundColor}); } 

That should give you something that is roughly equivalent to this in PHP (I made up pretend data):

Array( [0] => Array( "src" => "logo.png", "alt" => "My Logo!", "background" => "#ffffff" ) ) 

I hope this helps!

var photos = []; var imgs = document.getElementById("photos").getElementsByTagName("img"); for(var i=0;i<imgs.length;i++){ photos.push({ src:imgs[i].src, alt:imgs[i].alt, background:imgs[i].style.backgroundColor }); } 

That should give you something that is roughly equivalent to this in PHP (I made up pretend data):

Array( [0] => Array( "src" => "logo.png", "alt" => "My Logo!", "background" => "#ffffff" ) ) 

I hope this helps!

Source Link
tau
  • 6.8k
  • 10
  • 41
  • 65

var photos = []; var imgs = document.getElementById("photos").getElementsByTagName("img"); for(var i=0;i<imgs.length;i++){ photos.push({src:imgs[i].src,alt:imgs[i].alt,background:imgs[i].style.backgroundColor}); } 

That should give you something that is roughly equivalent to this in PHP (I made up pretend data):

Array( [0] => Array( "src" => "logo.png", "alt" => "My Logo!", "background" => "#ffffff" ) ) 

I hope this helps!