have a need to work with the pre-defined array dumped below. It is being sent to me via an API as serialized PHP output. I need to take each image and request additional info on it. Since I don't know what image numbers are in array....or how many....and they can be changing... how can I loop thru these image? I basically need to load each id. There doesn't seem to be a key...If I'm reading it right the key is the image id.
Below is the serialized output I'm delivered.
a:3:{s:4:"stat";s:2:"ok";s:6:"method";s:18:"smugmug.images.get";s:6:"Images";a:30:{i:109589275;a:1:{s:2:"id";i:109589275;}i:115701415;a:1:{s:2:"id";i:115701415;}i:115702224;a:1:{s:2:"id";i:115702224;}i:115710764;a:1:{s:2:"id";i:115710764;}i:115779101;a:1:{s:2:"id";i:115779101;}i:115919629;a:1:{s:2:"id";i:115919629;}i:115919633;a:1:{s:2:"id";i:115919633;}i:115919638;a:1:{s:2:"id";i:115919638;}i:115919642;a:1:{s:2:"id";i:115919642;}i:115931127;a:1:{s:2:"id";i:115931127;}i:115959121;a:1:{s:2:"id";i:115959121;}i:116250766;a:1:{s:2:"id";i:116250766;}i:116430257;a:1:{s:2:"id";i:116430257;}i:116430260;a:1:{s:2:"id";i:116430260;}i:116430269;a:1:{s:2:"id";i:116430269;}i:116430271;a:1:{s:2:"id";i:116430271;}i:116430274;a:1:{s:2:"id";i:116430274;}i:116430277;a:1:{s:2:"id";i:116430277;}i:116430280;a:1:{s:2:"id";i:116430280;}i:116430284;a:1:{s:2:"id";i:116430284;}i:116430288;a:1:{s:2:"id";i:116430288;}i:116430291;a:1:{s:2:"id";i:116430291;}i:116430296;a:1:{s:2:"id";i:116430296;}i:116430303;a:1:{s:2:"id";i:116430303;}i:116430305;a:1:{s:2:"id";i:116430305;}i:116449082;a:1:{s:2:"id";i:116449082;}i:116449633;a:1:{s:2:"id";i:116449633;}i:116455134;a:1:{s:2:"id";i:116455134;}i:117001585;a:1:{s:2:"id";i:117001585;}i:117001599;a:1:{s:2:"id";i:117001599;}}}
I've been working directly with this data from the API call. Should I attempt to move it back into an array for more control?
the FOREACH command below can cycle thru 30 time put I'm unable to find the
right command to print ...and also to load into the loop to be able to query the API again for addition image info. none of the echo or print comands below dumped the image id. If I remember the just printed 'Array'. ($phpus2b is unserialized)
foreach ($phpus2b['Images'] as $phpus2b['id'] )
{
$holdimage = $phpus2b['Images'] ['id'];
echo $holdimage;
$holdid = $phpus2b['id'];
echo $holdid;
$holdim = $phpus2b['Images'];
echo $holdim;
print $phpus2b['Images'];
print $phpus2b['id'];
I've also tried the method below to print the values.. (and in the future to load the image number)
for($i = 0; $i < count($phpus2b['Images']); $i++) {
$value = $phpus2b['Images'][$i];
echo $value;
but PHP fails (well my code fails) to resolve the [$i]
Below is a var dump...
["Images"]=>
array(30) {
[109589275]=>
array(1) {
["id"]=>
int(109589275)
}
[115701415]=>
array(1) {
["id"]=>
.
.
.30 total
.
.
}
[117001599]=>
array(1) {
["id"]=>
int(117001599)
}
}
}
I see alot of stuff in the manual about arrays. But most assume that your PHP script has built them. That might be the basic of my problems (or misunderstand).
The arrary values have be delivered in serialized output. Do I need to handle that differently ?