SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    concatinating to make a variable?

    Is there a way to concatenate to make a variable? For example, I have a loop that looks like so:
    Code:
    $j=1;
    while($j <10 ){ 
    $VarNum="This is the value of variable number ".$j."<br>";
    $j++;
    }
    and I want the variable to increase in number so that I would have $VarNum1, $VarNum2, $VarNum3, etc.... I was thinking I would do something like this
    Code:
    $VarNum.$j="This is the value of variable number ".$j."<br>";
    but that doesn't seem to work. Any suggestions?

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    ${'VarNum' $j
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that works!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •