Using the value of a variable as a variable name

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

    #1

    Using the value of a variable as a variable name

    Hi there,

    Is there a way to use a variable's value as part of a variable's name?

    i.e

    $var = array();
    $var[id] = "somewhere" ;
    $($var[id] . "outthere") = "asd";
    //Get above line to translate to: $somewhereoutth ere = "asd";

    I hope I've explained myself fully, and I hope that this hasn't been
    asked before.

    Thanks,
    TheTeapot

  • Juha Suni

    #2
    Re: Using the value of a variable as a variable name

    TheTeapot wrote:[color=blue]
    > Is there a way to use a variable's value as part of a variable's name?[/color]

    Read about variable variables:


    --
    Suni


    Comment

    • TheTeapot

      #3
      Re: Using the value of a variable as a variable name

      Thank you - I was trying to use [ and ], but they didn't work.

      Must remember - { and }!

      Thanks,
      TheTeapot

      Comment

      Working...