duanjiongzhen2523 2015-12-22 23:59
浏览 49

php数组没有设置新的键和值

I have a class with two arrays as members. $member_albums and $member_photos.

As part of the initialization I am taking data from both and building urls for each photo to be added as a value in the member photos array. This is being done by a method within the class. However, I cannot seem to add values or even change existing ones. Help?

Here is the method -

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');
                    }
                }                   
            }
        }
    }
}

Edit: Adding example of arrays data structure.

$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 ) )
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)