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!