Re: Odd array_push issue

From: Date: Wed, 11 May 2011 20:30:05 +0000
Subject: Re: Odd array_push issue
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-312770@lists.php.net to get a copy of this message
On 11 May 2011 22:23, Richard S. Crawford <richard@underpope.com> wrote: > I'm encountering what appears to be a bug in array_push when I try using > that function to add objects to an array. For example... > > A = Object 1 > B = Object 2 > > If I execute the following code: > > array_push(objectarray, A); > array_push(objectarray, B); > > ...I expect the contents of $objectarray to be: > > [0] = A > [1] = B > > Instead, the last object pushed onto the array is repeated throughout the > array. In other words, instead of the above, I get this: > > [0] = B > [1] = B > > Can anyone enlighten me as to why this is happening? I've looked through bug > reports but haven't found anything, which leads me to think that perhaps my > own code is at fault. > If you could post some more of your code, it would be easier to check if your code is at fault or not. Regards Peter -- <hype> WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 </hype>

« previous php.general (#312770) next »