multi-dimension arrays in PHP
Robert.Edwards at anu.edu.au
Thu Mar 6 18:02:15 EST 2003
Not really a Linux question, per say, but it is running on a Linux-based
I have a multi-dimensioned array that I am saving in the super-global session
variable, $_SESSION, thus:
$myarray[$x][$y][$z] = "some string";
$_SESSION['myarray'] = $myarray;
>From the documentation on arrays in the online PHP manual it states that
assigning arrays like this will involve value copying:
"You should be aware, that array assignment always involves value copying. You
need to use the reference operator to copy an array by reference."
I add other values to $myarray, but I don't expect these to be saved in the
When the next page loads, I do this:
$myarray = $_SESSION['myarray'];
and now $myarray does contain the extra added values, which implies that they
were also saved into the session store. What I really want is to only see the
original stuff that was saved in $myarray before I saved it in the session.
Anyone know why this might be happening, how to avoid it, or where I should
ask for more help?
More information about the linux