$("var" . $i) ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jan Rasche

    $("var" . $i) ?

    Hi All,

    Please some help about building a var name:

    for($i=1;$i<5;$ i++) {
    $query=$("var" . $i);
    //$var1
    //$var2
    //$var3
    //$var4
    }

    Thank you in advance!

    Jan

    --




    'I worry about my child and the Internet all the time, even though she's
    too young to have logged on yet. Here's what I worry about. I worry that
    10 or 15 years from now, she will come to me and say 'Daddy, where were
    you when they took freedom of the press away from the Internet?'
    --
    --Mike Godwin, Electronic Frontier Foundation <http://www.eff.org/br/>
  • Henk Burgstra

    #2
    Re: $(&quot;var&quo t; . $i) ?

    On Sat, 17 Apr 2004 20:30:28 +0200, Jan Rasche wrote:
    [color=blue]
    > Hi All,
    >
    > Please some help about building a var name:
    >
    > for($i=1;$i<5;$ i++) {
    > $query=$("var" . $i);
    > //$var1
    > //$var2
    > //$var3
    > //$var4
    > }
    >[/color]
    for ($i=1; $i<5; $i++) {
    $a = "var$i";
    $query=$$a;
    }

    Regards,
    Henk Burgstra

    Comment

    • Jan Rasche

      #3
      Re: $(&quot;var&quo t; . $i) ?

      Henk Burgstra wrote:[color=blue][color=green]
      >>[/color]
      >
      > for ($i=1; $i<5; $i++) {
      > $a = "var$i";
      > $query=$$a;
      > }[/color]

      Hi Henk,

      Thats it - thank you!

      Regards, Jan




      'They understood that the future would be built on the free exchange of
      information; decentralisatio n; enriching the world's knowledge of
      computing by increasing accessibility.'
      --Steven Levy, Hackers. Heroes of the Computer Revolution.


      Comment

      • Jeppe Uhd

        #4
        Re: $(&quot;var&quo t; . $i) ?

        Jan Rasche wrote:[color=blue]
        > Hi All,
        >
        > Please some help about building a var name:
        >
        > for($i=1;$i<5;$ i++) {
        > $query=$("var" . $i);
        > //$var1
        > //$var2
        > //$var3
        > //$var4
        > }
        >[/color]

        Either the solution provided by Henk or this:

        for($i=1;$i<5;$ i++) {
        $query=${"var" . $i};
        }

        --
        MVH Jeppe Uhd - NX http://nx.dk
        Webhosting for nørder og andet godtfolk


        Comment

        Working...