im working on a loop that produces a row of table cells with info in them...all the info is stored in variables numbered 1 to 10, like this:
$o1
$o2
$o3
...
$o10
now what i want to do is, inside that loop, cycle through the 10 different variables...but are variables inside variables allowed? heres the basic structure i have so far:
Yes they are. I didn't check if your script will work, but you can use variables with another variable.
Example
$o1 = 0;
$o2 = $o1 + 1;
Now the value of o2 is NOT $o1 + 1, the value of o2 is 1. When you point to a variable in another variable, the contents of the variable are actually copied, not just a pointer to the first variable.
Just a guess, but the same is probably true for an array.
so brendan, youre saying that something like this:
PHP Code:
$contents = "<b>$o".$i.":</b>";
should work fine? so the first time through the loop, it should print out the value of $o1? alright then, ill try it out...otherwise ill try to work the code so $o is set to an array...it should work...
oh, another question: to set the values of an array, do you have to use the array() function? or can values simply be set like:
$o[1] = 8;
$o[2] = 5;
etc etc, without even touching the array() function?
well the variables in variables thing doesnt work, so i had to redo my entire section of code in order to implement arrays instead...then $o[$i] worked fine
but i have ONE last question, and then i think ill be done this script and it can go into my free script database (check out my sig - CrossFade Studios)...
yeah i used $clear = $_POST["clear"]; just cause i find it easier to work with if i have to type it out a million times...the thing is that i wasnt sure what value it gave out when the checkbox was checked - for things like textboxes and such, the value is returned, but for a checkbox, both the name and value are already defined...anyways it works now, so problem is solved
Bookmarks