On Fri, Nov 18, 2011 at 10:25 AM, Aaron Fulton <[email protected]> wrote:
> Hi,
> This should be an easy one but the answer is alluding me this morning. I
> have a data structure:
>
> $myobject->100->property1;
> $myobject->100->property2;
>
> $myobject->101->property1;
> $myobject->101->property2;
>
> I'm attempting to set a property like this however it does not work. I
> suspect it's because my ID is numeric. Am I able to do this and if not
> want is the best workaround?
> foreach ($myobject as $id > info) {
> $myobject->{$id}->property3 1;
> }
This works fine - you can just do $myobject->{101}->property1 to
access numeric properties.
eg http://codepad.viper-7.com/L1qjbB
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]