471,072 Members | 1,444 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,072 software developers and data experts.

"for" loops with variable names...

using Flash, I'm sending a bunch of variables to my php script that have ordered names. What I want is to use a "for" loop to identify each variable. This is how I would do it in Flash but don't know how to do it in php...
Expand|Select|Wrap|Line Numbers
  1. for(i=0; i<3; i++){
  2.     this["Item"+i] = i;
  3. }
  5. // the above code would be identical to typing the following...
  7. Item0 = 0;
  8. Item1 = 1;
  9. Item2 = 2;
granted i know there's normally a $ for variables in php... but my real concern is how to get this["Item"+i] = i; to work.

Thanks for any help
Sep 4 '06 #1
1 1502
i found the answer...
Expand|Select|Wrap|Line Numbers
  1. for($i = 0; $i < 3; $i++){
  2.     ${"Item".$i} = $i;
  3. }
Sep 4 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

23 posts views Thread by Invalid User | last post: by
11 posts views Thread by David Morgenthaler | last post: by
32 posts views Thread by Toby Newman | last post: by
12 posts views Thread by Robbie Hatley | last post: by
34 posts views Thread by Frederick Gotham | last post: by
4 posts views Thread by MDR | last post: by
13 posts views Thread by xz | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.