Php array does not set new key and value

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

As part of the initialization, I take the data as from the URL to add each photo as a value in the participantโ€™s photo array. This is done by the method inside the class. However, I cannot add values โ€‹โ€‹or even modify 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 an example data structure for arrays.

$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 ) )
+1
source share

Source: https://habr.com/ru/post/1621714/


All Articles