468,249 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

"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. }
  4.  
  5. // the above code would be identical to typing the following...
  6.  
  7. Item0 = 0;
  8. Item1 = 1;
  9. Item2 = 2;
  10.  
  11.  
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 1439
i found the answer...
Expand|Select|Wrap|Line Numbers
  1. for($i = 0; $i < 3; $i++){
  2.     ${"Item".$i} = $i;
  3. }
  4.  
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
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.