* Edited my question after identifying the underscore problem.
Many thanks to choz who helped diagnose the problem *
* Description *
I have a class with two members that respectively store data about albums and photos. In the constructor, I populate them with data extracted from the database query. These queries return an object with an array that is a protected member of the object.
I tried to add a new key and value to an object containing an associative array, mistakenly treating it as a simple array. This new key and value have not been set. Presumably because the element of the array of objects is protected. See Dump var below, where Object dump begins: ["Data": protection]. This is problem? And if so, what is the best way to create my own copies that I can freely manipulate?
//Object with array of associative album arrays.
//Each inner album array is defined by unique key ='albumID'.
private $member_albums;
//array of objects holding associative photo arrays.
//Each inner photo array is defined by unique key ='albumID'.
private $member_photos;
This is the method used to add the key and value -
private function add_Photo_Url_To_Photos_Data_Array(){
if( $this->member_albums && $this->member_photos){
if($this->member_albums['Count'] > 0 ){
foreach ($this->member_albums['Items'] as $albumArr) {
$curr_AlbumId = $albumArr['albumID']['S'];
if( $this->member_photos[$curr_AlbumId]['Count'] > 0){
foreach( $this->member_photos[$curr_AlbumId]['Items'] as &$photosArr) {
$url = $this->build_Photo_Url($photosArr, $curr_AlbumId);
$photosArr['img_url'] = array('S' =>
$url);
echo ' <br>Img URL = ' . $photosArr['img_url']['S'];
}
}
}
}
}
But if I try and echo "img_url" from the array element $ this-> member_photos, it does not exist.
Thanks.
*** EDIT 3 **** Adding var_dump ($ this-> member_albums) and var_dump ($ this-> member_photos)
var_dump ($ this-> member_albums)
object(Guzzle\Service\Resource\Model)
["structure":protected]=> NULL ["data":protected]=> array(3) {
["Count"]=> int(2)
["Items"]=> array(2) {
[0]=> array(7) {
["PlaceLong"]=> array(1) { ["N"]=> string(1) "0" }
["AlbumId"]=> array(1) { ["S"]=> string(7) "album_1" }
["Title"]=> array(1) { ["S"]=> string(5) "Test1" }
["UserId"]=> array(1) { ["S"]=> string(36) "810725E5-D235-43F7-AA50-4CCDACD6AB36" }
["Year"]=> array(1) { ["N"]=> string(1) "0" }
["PlaceLat"]=> array(1) { ["N"]=> string(1) "0" }
["Timestamp"]=> array(1) { ["N"]=> string(16) "472572846.470462" }
}
var_dump ($ this-> member_photos)
array(2) {
["album_1"]=> object(Guzzle\Service\Resource\Model)
["structure":protected]=> NULL ["data":protected]=> array(3) {
["Count"]=> int(5)
["Items"]=> array(5) {
[0]=> array(8) {
["ShotId"]=> array(1) { ["S"]=> string(6) "Photo2" }
["AlbumId"]=> array(1) { ["S"]=> string(7) "album_1" }
["UserId"]=> array(1) { ["S"]=> string(16) "1111-11111-11111" }
["Year"]=> array(1) { ["N"]=> string(1) "0" }
["Discovery"]=> array(1) { ["N"]=> string(1) "0" }
["Timpstamp"]=> array(1) { ["N"]=> string(14) "472572840.3845" }
["ExtractedPhotoId"]=> array(1) { ["S"]=> string(32) "Photo2_0-0-746-0-0-1000-746-1000" }
["ManualEdit"]=> array(1) { ["N"]=> string(1) "0" }
}