I need a way to declare a variable to use in while
loop like this:
$x = 1;
while ($x < 5){
echo $row['img$x'];
$x++;
}
In my case, this returned a syntax error.
I need a way to declare a variable to use in while
loop like this:
$x = 1;
while ($x < 5){
echo $row['img$x'];
$x++;
}
In my case, this returned a syntax error.
Two options:
$row['img' . $x]
// or
$row["img$x"]
Use double quotes ""
if you want to use string interpolation and .
for string concatenation.