references in arrays
| From: | Ron Korving | Date: | Thu, 15 Sep 2005 10:35:48 +0000 |
| Subject: | references in arrays | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-18954@lists.php.net to get a copy of this message | ||
Hi,
For performance' sake, I have to know if this is true:
Is it the case that when I do this:
<?php
$array = array("one" => array(0,1,2), "two" => array(4,5,6));
$one = $array["one"];
?>
That $one is not a copy, but a reference to $array["one"] and will only
become a copy when I alter the contents of $one? I know this is the case for
regular variables, but does this also go for contents of arrays? If not, I
need to use the ampersand like I used to. But if it really is just a
reference, that would be good to know as I shouldn't be using the ampersand
at all (mistakingly thinking it's a performance advantage when it's actually
not).
Thanks,
Ron