[Phpwm] updating an array

David Goodwin david at codepoets.co.uk
Thu Oct 19 12:52:56 BST 2006


alan dunn wrote :
> 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

It's probably due to php using pass-by-value and not pass-by-reference

See http://uk.php.net/manual/en/language.variables.php (I think) which
may help...

David.

-- 
David Goodwin 

[ david at codepoets dot co dot uk ]
[ http://www.codepoets.co.uk       ]



More information about the Phpwm mailing list