"for" loops with variable names...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ralgoth
    New Member
    • Sep 2006
    • 2

    #1

    "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...
    Code:
    for(i=0; i<3; i++){
    	this["Item"+i] = i;
    }
    
    // the above code would be identical to typing the following...
    
    Item0 = 0;
    Item1 = 1;
    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
  • Ralgoth
    New Member
    • Sep 2006
    • 2

    #2
    i found the answer...
    Code:
    for($i = 0; $i < 3; $i++){
    	${"Item".$i} = $i;
    }

    Comment

    Working...