[PHP] Class var not retaining values

2001-05-21 Thread Bob
I have a class defined with a var $reasons that I will use as an array. The code to add to it is: function AddReason($score, $reason, $id) { static $index = 0; $this->reasons[$index] = "$score|$reason|$id"; for ($i = 0; $i < $index; $i++) { $out = $this->reasons[$i]; echo "$out..

Re: [PHP] Class var not retaining values

2001-05-21 Thread Markus Fischer
On Mon, May 21, 2001 at 05:58:06PM -0400, Bob wrote : > I have a class defined with a var $reasons that I will use as an array. The > code to add to it is: > > function AddReason($score, $reason, $id) > { > static $index = 0; > $this->reasons[$index] = "$score|$reason|$id"; > for ($i =

Re: [PHP] Class var not retaining values

2001-05-21 Thread Peter Dudley
Could it be that you need your for loop to iterate <= instead of < ? As it is, I don't think it will ever show anything. After all, you are setting $index to 0 at the beginning of the function every time you call it. My guess is you actually want to keep track of $index as an instance variable

Re: [PHP] Class var not retaining values

2001-05-22 Thread Chris Sano
Is the class variable declared as an array? class test{ var $reasons = array(); function addReason( $score, $reason, $id ) { $reasons[ $index ] = "$score|$reason|$id"; } } Hope this helps, -C ""Bob"" <[EMAIL PROTECTED]> wrote in message 9ec2rm$etg$[EMAIL PROTECTED]">n