I'm developing front-end code for a web application, and ran into an odd piece of trouble with a custom object. When I request the object and use print_r()
I get this (the object is a lot bigger; just cut it to the relevant code):
MemberInfo Object
(
[meta_data] => Array
(
[email_recommendations] => true
[email_updates] => false
)
)
To change something in the MemberInfo object, I just update its properties and send it back to the backend with a second function. So for instance, the page is loaded once (which gives us the object shown above), then I send a POST request with changes on a second load of the page. During the second load, I fetch the object above, set one field differently based on the POST with something like $memberInfo->meta_data['email_recommendations'] = 'false';
and then use that version of the object to populate the page after running the update function (which is something like updateMember($memberInfo);
). However, once I've changed the object property value print_r()
shows me something different:
MemberInfo Object
(
[meta_data] => {\"email_recommendations\":\"false\",\"email_updates\":\"false\"}
)
I'm sure I'm overlooking something very stupid; does anyone have a good idea of what I should be looking for? I checked, and the backend code isn't passing by reference (the function call is updateMember(MemberInfo $memberInfo);
) but I'm a little shaky on my PHP 5 object handling so I'm not sure what might be going wrong.
I don't expect in-depth debugging; I just need to know the general direction I should be looking for what is causing this change in a property that by all rights should be an array.
Thanks in advance!