I need the variables u1, u2, u3, u4 ... u559 and u560 to be set to # in PHP.
I have tried:
for ($x = 0; $x <= 560; $x++) {
$u{$x} = "#"; }
But it didn't seem to work. Any help?
I need the variables u1, u2, u3, u4 ... u559 and u560 to be set to # in PHP.
I have tried:
for ($x = 0; $x <= 560; $x++) {
$u{$x} = "#"; }
But it didn't seem to work. Any help?
I think you're best off making a single string, then assigning that string as a variable name.
for ($x = 0; $x <= 560; $x++) {
$var = 'u' . $x;
$$var = "#";
}
However, wouldn't an array fit your purposes?
for ($x = 0; $x <= 560; $x++) {
$u[$x] = "#";
}