Another quick PHP question... this one about arrays

BeauJangles

Lifer
Aug 26, 2001
13,941
1
0
particularly about the $_POST array, although it doesn't really make a difference.

Basically, I have a form with input fields created through a for loop. So they have names like opponent0, opponent1, opponent2, etc.

I tried checking these by creating another for loop which adds their values to a $query variable, but it won't accept the variables as indexes. It tries to read the variable name as the index.

Is there any way around this?

 

Zugzwang152

Lifer
Oct 30, 2001
12,134
1
0
the problem is with how you're nesting your quotes.

single quotes ->' take the literal string enclosed with them.

double quotes -> " will do what you want, and parse the variable name as its value
 

BeauJangles

Lifer
Aug 26, 2001
13,941
1
0
yeah i just realized that. I came back to AT to edit the thread. Thanks for the help though... soemtimes i feel like an idiot.