[eluser]earlyriser[/eluser]
Hi.
I would like to change a variable name in a loop, from a view file but I cann't get it work.
My code is
Code:
<?=$row->keyword1?>,<?=$row->keyword2?>,<?=$row->keyword3?>,<?=$row->keyword4?>
<?php for ( $counter = 1; $counter < 5; $counter++)
{
echo ${'row->keyword'.$counter};
}?>
The first line is for testing purposes and it writes some keywords from the query results rows. It works fine.
With the FOR loop I want to have the same result, but I got and error:
Severity: Notice
Message: Undefined variable: row->keyword1
What is the correct way to do this? I have tried also
echo ${'$row->keyword'.$counter};
with the same error
Thanks.