[Phpwm] updating an array
Phil Beynon
phil at infolinkelectronics.co.uk
Thu Oct 19 14:01:26 BST 2006
> I am simply(!) trying to read through an array comparing the key with a
> string (product code) and where I find a match add the corresponding
> quantity to the existing quantity.
>
> if($match) {$prodarray[$key1] = $prodarray[$key1] + $qty2; }
>
> If I echo $prodarray[$key1] immediately after this line I get the
> increased value. But after continuing to cycle through the array the
> changed value is lost.
>
> I have some recollection of a group discussion about arrays being read
> into memory, or proxy values or some such? Can anyone shed light on how
> I get that value into the array?
>
> thanks, alan dunn
Alan,
PHP supports "pass by reference" variables by prefixing a variable with an
ampersand (&)(PHP4 onwards).
By default variables are "passed by value".
Phil
More information about the Phpwm
mailing list