I just have a simple for loop, however I keep getting this error and I cannot figure out what is wrong with the loop. I have researched the error and it is most likely a missing semi-colon or parentheses etc. Something simple...
for ($t=1; $t<=16; ++$t)
{
$game$t = $_POST["game$t"];
}
The problem is that you did not look up the manual page for the feature that you're trying to use. Something simple, indeed.
I think you're looking for ${game.$t}
(not $game$t
) in order to create a "family of variables" whose names all share a common prefix:
for ($t=1; $t<=16; ++$t) {
${game.$t} = $_POST["game$t"];
}
But I'd really suggest that you use an array instead:
$games = Array();
for ($t=1; $t<=16; ++$t) {
$games[$t] = $_POST["game$t"];
}
$game$t
is not a valid variable name.
You can use something like $game{$t}
instead
You cannot write $game$t
. If you really need variable variable names (I advise against it, it's not the best practice), you have to write it like this:
$name = "game$t";
$$name = $_POST["game$t"];