cffaq.com


Hosted and maintained by Ben Forta. Designed by Trilemetry.
Language:
    © 2002-2007 Ben Forta. All Rights Reserved  
<Home> <FAQ> <Question> <About>

Question

How can I create a variable using a variable in the variable name?
The trick is to enclose the entire variable name in quotes, and then use your variable within the name enclosed within # characters. An example of this is shown below:
<!--- Set i --->
<CFSET i=1>
<!--- Create product1 variable dynamically --->
<CFSET "product#i#"="apple">
<!--- Display product1 variable --->
<CFOUTPUT>#product1#</CFOUTPUT>

Comments


Add Your Comments

Your Name:
Your E-Mail:
Comment:
Verification: Copy the text on the left:

<submit question>