Yeti wrote:
>> //for each row I want to add percentage as new key->value pair
>> // but it gives error 'Undefined variable:
>> percentage'
>> $row->$percentage = ($browseCount / $totalCount ) * 100;
>
> Obviously you get the error because $percentage is not defined ..
>
> I did not fully understand what you wanted.
>
> Here is a list of what should work ...
>
> #Set a variable percentage in $row
> $row->percentage = ($browseCount / $totalCount ) * 100;
>
> #Set a variable with name $percentage in $row
> $percentage = ($browseCount / $totalCount ) * 100;
> $row->$percentage = $percentage;
>
I don't think the above will work either, afaik php doesn't allow you to have
variable names start with numbers. Also, there is a high possibility
that $percentage would end up being a float.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php