smugmug.images.get output questions

kansaschuckkansaschuck Registered Users Posts: 50 Big grins
smugmug.images.get returns image numbers in an array with the key being the image number?

[Images] => Array
(
[109589275] => Array
(
[id] => 109589275
)

[115701415] => Array
(
[id] => 115701415
)

if I want a script to loop thru 30+ images in the album how would I address the elements by a key? I'm not sure how to work/address each image in this array.

Thanks... Chuck

Comments

  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited December 19, 2006
    Chuck,

    I am using the JSON api and javascript, but something similar should exist for php...
    for (var i in rst.Images) {
        sTinyURL = rst.Images[i].TinyURL;
        sThumbURL = rst.Images[i].ThumbURL;
        sSmallURL = rst.Images[i].SmallURL;
        sMediumURL = rst.Images[i].MediumURL;
        sLargeURL = rst.Images[i].LargeURL;
        sOriginalURL = rst.Images[i].OriginalURL;
        sGetImageID = rst.Images[i].id;
    }
    
    So you use a for...in loop to iterate each element.

    EDIT...it's foreach for PHP..
    foreach (array_expression as $value)
        statement
    foreach (array_expression as $key => $value)
        statement
    
    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • kansaschuckkansaschuck Registered Users Posts: 50 Big grins
    edited December 19, 2006
    devbobo wrote:
    Chuck,

    I am using the JSON api and javascript, but something similar should exist for php...
    for (var i in rst.Images) {
        sTinyURL = rst.Images[i].TinyURL;
        sThumbURL = rst.Images[i].ThumbURL;
        sSmallURL = rst.Images[i].SmallURL;
        sMediumURL = rst.Images[i].MediumURL;
        sLargeURL = rst.Images[i].LargeURL;
        sOriginalURL = rst.Images[i].OriginalURL;
        sGetImageID = rst.Images[i].id;
    }
    
    So you use a for...in loop to iterate each element.

    EDIT...it's foreach for PHP..
    foreach (array_expression as $value)
        statement
    foreach (array_expression as $key => $value)
        statement
    
    Cheers,

    David



    David, Thanks!

    I had been looking and using foreach but did a deeper look at it.
    I understood the $key needed to be supplied by the users. and so I was try to define the $key from the array.....but it's filled in by the function and it just the info from the array I needed.

    learning,

    thanks again... :D
    Chuck
Sign In or Register to comment.