MySQL Forums
Forum List  »  PHP

Creating a variable variable name
Posted by: Tom Carpenter
Date: November 20, 2010 08:44PM

I've read about variable variables and string concatenation and could use some advice on the best approach for an html form I'm working on.

When I generate the form I sometimes loop sections that repeat.

One such loop is like this:

Phone1 Description1
Phone2 Description2
Phone3 Description3

The table record actually has fields Phone1, Description1, Phone2, ...etc. and I equate them to $phone1, $description1, $phone2, etc.

What I tried to do was to use $i to control to loop and then echo:

value='$phone$i' or value '$description$i' in an <input> statement but that doesn't work.



Options: ReplyQuote

Written By
Creating a variable variable name
November 20, 2010 08:44PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.