accessing nested unknown unserialized objects [message #183638] |
Mon, 04 November 2013 20:37 |
catseye.chandra
Messages: 1 Registered: November 2013
Karma:
|
Junior Member |
|
|
Hello PHP users,
I'm currently fiddling with phpgallery 1.x import/tweaking, and by using unserialize got access to an album metadata.
unserialize gives a big array, with nested objects as each elt.
I cannot find the right way to wright the accessor to two fields of real interest :
$this->image->name
and
$this->caption
for now I got :
<?
$fh = fopen("photos.dat", "r");
$buf = fread($fh, 1024000);
$arr = unserialize($buf);
foreach ($arr as &$o) {
print $o->image->name;
print $o->caption;
flush();
}
?>
also:
<?
$fh = fopen("photos.dat", "r");
$buf = fread($fh, 1024000);
$arr = unserialize($buf);
foreach ($arr as &$o) {
//print_r($o);
printf("%s : %s\n", $o->image->name, $o->caption);
flush();
};
?>
but nothing get printed :-(
Thanks for any help - I'm a beginner.
--
Array
(
[0] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => AlbumItem
[image] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Image
[name] => aaa
[type] => jpg
[width] => 700
[height] => 525
[resizedName] => aaa.sized
[thumb_x] =>
[thumb_y] =>
[thumb_width] =>
[thumb_height] =>
[raw_width] => 1024
[raw_height] => 768
[version] => 38
)
[thumbnail] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Image
[name] => aaa.thumb
[type] => jpg
[width] => 210
[height] => 158
[resizedName] =>
[thumb_x] =>
[thumb_y] =>
[thumb_width] =>
[thumb_height] =>
[raw_width] => 210
[raw_height] => 158
[version] => 38
)
[preview] =>
[caption] => Gymnocalycium saglione - juin 01
[hidden] =>
[highlight] => 1
[highlightImage] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Image
[name] => aaa.highlight
[type] => jpg
[width] => 200
[height] => 150
[resizedName] =>
[thumb_x] =>
[thumb_y] =>
[thumb_width] =>
[thumb_height] =>
[raw_width] => 200
[raw_height] => 150
[version] => 38
)
[isAlbumName] =>
[clicks] => 4659
[keywords] =>
[comments] =>
[uploadDate] => 994366657
[itemCaptureDate] => 992529433
[exifData] => Array
(
[File size] => 160119 bytes
[File date] => 2004:12:29 22:25:11
[Camera make] => NIKON
[Camera model] => E880
[Date/Time] => 2001:06:14 16:37:13
[Resolution] => 1024 x 768
[Flash used] => No
[Focal length] => 13.9mm
[Exposure time] => 0.0080 s (1/125)
[Aperture] => f/9.4
[ISO equiv.] => 100
[Metering Mode] => matrix
[Exposure] => program (auto)
)
[owner] => 988373499_1755202938
[extraFields] => Array
(
)
[rank] => 0
[version] => 38
[emailMe] => Array
(
)
[imageAreas] =>
)
|
|
|