Is there a way to do this with variables?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brandon Lamb

    #1

    Is there a way to do this with variables?

    ok so I have for example $f1, $f2, $f3, $f4... $f22.

    i want a

    for ($i = 1; $i <= 22; $i++)
    {
    if ($f$i == 1) { } // The variable should turn into $f1, $f2, etc
    }


  • Tim Van Wassenhove

    #2
    Re: Is there a way to do this with variables?

    In article <1080dedop704ge 9@corp.supernew s.com>, Brandon Lamb wrote:[color=blue]
    > ok so I have for example $f1, $f2, $f3, $f4... $f22.
    >
    > i want a
    >
    > for ($i = 1; $i <= 22; $i++)
    > {
    > if ($f$i == 1) { } // The variable should turn into $f1, $f2, etc
    > }[/color]

    eval?

    --

    Comment

    • FLEB

      #3
      Re: Is there a way to do this with variables?

      Regarding this well-known quote, often attributed to Brandon Lamb's famous
      "Fri, 16 Apr 2004 12:36:43 -0700" speech:
      [color=blue]
      > ok so I have for example $f1, $f2, $f3, $f4... $f22.
      >
      > i want a
      >
      > for ($i = 1; $i <= 22; $i++)
      > {
      > if ($f$i == 1) { } // The variable should turn into $f1, $f2, etc
      > }[/color]

      Curly braces:
      ${"f$i"} == $f1
      (assuming $i == 1)

      --
      -- Rudy Fleminger
      -- sp@mmers.and.ev il.ones.will.bo w-down-to.us
      (put "Hey!" in the Subject line for priority processing!)
      -- http://www.pixelsaredead.com

      Comment

      • Andy Hassall

        #4
        Re: Is there a way to do this with variables?

        On Fri, 16 Apr 2004 12:36:43 -0700, "Brandon Lamb" <brandon@olypen .com> wrote:
        [color=blue]
        >ok so I have for example $f1, $f2, $f3, $f4... $f22.
        >
        >i want a
        >
        >for ($i = 1; $i <= 22; $i++)
        >{
        > if ($f$i == 1) { } // The variable should turn into $f1, $f2, etc
        >}[/color]

        Variable variables. But you'd be better off with an array.

        --
        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
        http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

        Comment

        Working...