Is there a function to turn strings into a variable?
Posted: Tue May 20, 2008 3:35 am
Hi,
Let me start off by saying that I'm quite new to this forum and uhh...hi.
Anywho, I'll also say that I design CMS's and such for a living - hence I'm not an idiot. This simply doesn't seem to be an easy question (though it should be...). Don't patronize me
.
Question:
Is there a way to join two or more strings together to create an object/variable?
Eg.
Now, as expected - that output 'apples_1'.
Unfortunaitly, as is evident above - I need to the above code to output 'I need to be displayed'.
In Actionscript 2.0, I can use
Thanks in advance,
Jamen
PS. PLEASE don't ask why this needs to be done. The answer is basically a new content control test I'm working on for ameture coders.
Let me start off by saying that I'm quite new to this forum and uhh...hi.
Anywho, I'll also say that I design CMS's and such for a living - hence I'm not an idiot. This simply doesn't seem to be an easy question (though it should be...). Don't patronize me
Question:
Is there a way to join two or more strings together to create an object/variable?
Eg.
Code: Select all
$apples_total=5;
$apples_1='I';
$apples_2='need';
$apples_3='to';
$apples_4='be';
$apples_5='displayed';
$apples_='apples_';
for ($i=1; $i<=$apples_total; $i++) {
print ($apples.$i);
}Unfortunaitly, as is evident above - I need to the above code to output 'I need to be displayed'.
In Actionscript 2.0, I can use
Code: Select all
apples_total=5;
apples_1='I';
apples_2='need';
apples_3='to';
apples_4='be';
apples_5='displayed';
apples_='apples_';
for (i=1; i<=apples_total; i++) {
trace (eval(apples_+i));
}Thanks in advance,
Jamen
PS. PLEASE don't ask why this needs to be done. The answer is basically a new content control test I'm working on for ameture coders.