Create many variables from a loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PHPstarter
    New Member
    • Jun 2009
    • 77

    Create many variables from a loop

    Hiya

    I was wondering how I could make a variable called
    $maxlen2, $maxlen4, etc.. with the same value as the digit in their name represents?

    I was able to do this by having a loop like this

    Code:
    for($Lengder=1; $Lengder<=300; $Lengder++)
    {
    $maxLen[$Lengder]=$Lengder;
    }
    But I would like to make this without having to use [] in my variable, because now I have to write $maxlen[3] instead of $maxlen3.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    IMHO, you're better off with an array, much better to handle that 300 variables. besides, what do you need those 300 explicit variables for anyway?

    Comment

    • PHPstarter
      New Member
      • Jun 2009
      • 77

      #3
      Heh I think we can disregard the topic, I found a much easier solution... >.>

      ^^ thx

      Comment

      Working...