I have the following:
$textq1 = 'text';
$textq2 = 'more text';
I have a loop:
for ($i = 1; $i <= 70; $i++) {
echo "<div>". $textq1." ";
}
Now....what I'd like to do is, within the loop have the 1
part of the $textq1
be the value of $i
.
Is that possible?
Change:
echo "<div>". $textq1." ";
To:
echo "<div>". ${'textq'.$i} ." ";
for (...)
{
echo "<div>{${textq$i}}</div>";
}
Take a look at this example about variable variables
in the PHP docs: http://www.php.net/manual/en/language.variables.variable.php#105282
$var = "textq{$i}";
echo "<div>". $$var." ";