concatenating variable names? possible?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vapulus
Forum Newbie
Posts: 3
Joined: Tue Dec 31, 2002 9:50 pm

concatenating variable names? possible?

Post by vapulus »

Okay, this should be a very simple thing, but I can't figure it out. It's been frustrating me for hours.

One one page, I've got an HTML form that has names generated with php using concatenation (sp?).
example: let's say the product number is 00A, the name of that field is set to 00Atype1. There will also be a 00Atype2 and 00Atype3.
So, in other words, for every product, there's a type1 field, a type2 field, and a type3 field.
These variables get passed to the next page.
I need to be able to access these variables again, but the problem is this.

00A is in variable $number...and there's a HUGE list of product numbers that go through this variable...so it's not something where I could just ask for each variable by it's name. I'm drawing it's number from a database...i just need to concatenate the number with "type1" to get the right response.

but i can't do this: echo($number.type1) or echo($number + type1) to get it to spit out the content of 00Atype1.

How do I do this? Hopefully this all made sense...it's kinda' hard to explain. I would be EXCEEDINGLY appreciative of anybody who could help. =P
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Have you checked out the Eval() function? You'll find it in the PHP manual on this site.
vapulus
Forum Newbie
Posts: 3
Joined: Tue Dec 31, 2002 9:50 pm

Post by vapulus »

Hmm...I'm failing to see how that would help, but I AM checking into it. There MAY be a way.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

vapulus
Forum Newbie
Posts: 3
Joined: Tue Dec 31, 2002 9:50 pm

Post by vapulus »

I am right now in the process of sending you my first born. =D
Post Reply