I think he was making an assumption about PHP based on how other
languages work. Everyone in the class is using Python or Java. He
is letting me use PHP, which hasn't been done before in this class.
Thanks for the tip on objects, I'll keep that in mind.
-Aaron
On Feb 26, 2007, at 10:16 AM
If your professor was referring to PHP, it's possible he could have been
referring to objects, not arrays. Objects are copied by reference, so if
you do this:
$Item = new Item;
$Item2 = $Item;
$Item2->setProductId('12');
print $Item->getProductId();
Your output will be '12'. If you want to cop
Indeed it does. Sorry! I was led to believe (by my cs professor)
that the default behavior when copying an array is that the copied
array is not a new instance but is tied by pointers to the old array,
so changes to one would change both of them. Other people in the
class are using pytho
Aaron Fischer wrote:
> I need to copy an array by value, not by reference.
PHP copies on demand, so as soon as you change one, it does what you'd
expect.
Chris
--
Chris Shiflett
http://shiflett.org/
___
New York PHP Community Talk Mailing List
http://
Daniel Convissor danielc-at-analysisandsolutions.com |nyphp dev/internal
group use| wrote:
Aaron:
On Sun, Feb 25, 2007 at 03:47:45PM -0500, Aaron Fischer wrote:
I need to copy an array by value, not by reference. Is there a best
way to do this? Right now I found serialize/unserialize wh
Aaron:
On Sun, Feb 25, 2007 at 03:47:45PM -0500, Aaron Fischer wrote:
> I need to copy an array by value, not by reference. Is there a best
> way to do this? Right now I found serialize/unserialize which seems
> to do the trick.
What ARE you talking about? Copying by value is the default b
On 2/25/07, Aaron Fischer <[EMAIL PROTECTED]> wrote:
I need to copy an array by value, not by reference. Is there a best
way to do this?
That depends on what the array contains. If it contains primitives
(numbers, chars, or booleans), you can just write a loop. If it contains
objects, just
I need to copy an array by value, not by reference. Is there a best
way to do this? Right now I found serialize/unserialize which seems
to do the trick.
Python has a function called deepcopy:
http://docs.python.org/lib/module-copy.html
For Java, it appears you can use a handmade function o