我有一个有两个数组作为成员的类。 $ member_albums和$ member_photos。
作为初始化的一部分,我从两者中获取数据并构建 每张照片的网址将作为成员照片数组中的值添加。 这是通过类中的方法完成的。 但是,我似乎无法添加值甚至更改现有值。 帮助
这是方法 -
private function build_urls() {
// If data was retrieved without errors
if ($this->member_albums && $this->member_photos) {
// If user has albums
if ($this->member_albums['Count'] > 0) {
// for number of albums
for ($x = 0; $x < $this->member_albums['Count']; $x++) {
// current album ID
$curr_AlbumId = $this->member_albums['Items'][$x][MEMBER_ALBUM_ID]['S'];
// if current album contains photos
if ($this->member_photos[$curr_AlbumId]['Count'] > 0) {
// for number of photos in current album
for ($y = 0; $y < $this->member_photos[$curr_AlbumId]['Count']; $y++) {
// add url key and value to this photo item array
$this->member_photos[$curr_AlbumId]['Items'][$y]['url'] = array('S' =>
'http://www.example/somephoto.jpg');
}
}
}
}
}
}
修改 添加数组数据结构的示例。
$member_albums -
[Count] => 1 [Items] => Array ( [0] => Array ( [Timestamp] => Array ( [N] => 468839229.371792 ) [Year] => Array ( [N] => 0 ) [UserId] => Array ( [S] => A05737C7-7D63-4EA8-8316-9D274DAE1BD0 ) [AlbumId] => Array ( [S] => album_3 ) )
$member_photos -
[Count] => 9 [Items] => Array ( [0] => Array ( [ShotId] => Array ( [S] => Photo4 ) [AlbumId] => Array ( [S] => album_3 ) [UserId] => Array ( [S] => A05737C7-7D63-4EA8-8316-9D274DAE1BD0 ) [Year] => Array ( [N] => 0 ) )