I am trying to create a very basic Flickr gallery using the Flickr API. What I want to achieve is sorting my pictures by tag. What I am using is jQuery.getJSON() so that I c
var arr = [];
arr[0] = [];
arr[0][0] = [];
arr[0][0][0] = "3 dimentional array"
Multi dimentional arrays have a lot of gaps unless they are used properly. A two dimensional array is called a matrix.
I believe your data contains a space seperate string called "tags" containing the tags and a single url.
var tagObject = {};
data.photoset.photo.forEach(function(val) {
val.tags.split(" ").forEach(function(tag) {
if (!tagObject[tag]) {
tagObject[tag] = [];
}
tagObject[tag].push(val.url_sq);
});
});
console.log(tagObject);
/*
{
"sea": ["url1", "url2", ...],
"things": ["url4", ...],
...
}
*/
I don't know how it returns multiple tags.
I think something like this should do what you want
var imageArray = [];
$.each(data.photoset.photo, function(i, item) {
// if the tag is new, then create an array
if(!imageArray[item.tags])
imageArray[item.tags] = [];
// push the item url onto the tag
imageArray[item.tags].push(item.url_sq);
});