Umm.... fun with variables... I guess?
Moderator: General Moderators
- FireyIce01
- Forum Newbie
- Posts: 6
- Joined: Fri Jun 21, 2002 2:16 pm
- Contact:
Umm.... fun with variables... I guess?
So here's my problem, I've got a bit of javascript, it goes ahead and writes a form, adds a bunch of hidden values to it, and then when I submit it passes it to PHP. Now, the problem is, in my PHP I don't exactly know how to deal with the variables... more precisely, I don't know how many are coming in, until they come in... and I'm sending a variable with that number, but I don't know how to write variables that are... well.. variable. If that made any sense I'm shocked... but anyway, exampel being this: I pass the form and it sends a variable $numberOf that tells me how MANY sets there are of the next variables. Then it passes $ID_1 as the first set and $ID_2 in the second set, and so on. Now really I would just like to make a for loop that takes $ID_ and concatonates the $numberOf to the end of the variable name... then I could pass all these into an array, and it'd be easier to deal with them... but I can't for the life of me figure out how to modify the variable name, and it doesn't seem to be a really common thing to do, as I haven't found a tutorial for it yet. Anyone have suggestions? Thanks.
- FireyIce01
- Forum Newbie
- Posts: 6
- Joined: Fri Jun 21, 2002 2:16 pm
- Contact:
I really need to get a couple books on this stuff... I have a PHP for Flash book, and it just has the basics of PHP... it's what got me into it... but anyway, I found a solution - ${"ID_".$numberOf"} seems to work with my version of PHP... so, that works, and I'll accept it for now... once I really learn this PHP stuff (shouldn't be too hard...) I'll try to do the count thing. Thanks a lot for the help though.