#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    5
    Rep Power
    0
    Is it possible to use a variable by assembling two or more other variable

    $varname = 3;
    $foo = "var";
    $bar = "name";
    $something = $foo$bar

    I know that probably won't work, but I want to do something like that.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    Yes, This can be done ....

    $varname = 3;
    $foo = "var";
    $bar = "name";
    $something = $foo.$bar

    echo $$something;

    will give u the desired result




    ------------------
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    15
    Yes this is possible see the example below:
    <?
    $varname = 3;
    $foo = "var";
    $bar = "name";
    $something = $foo.$bar;
    echo $$something;
    ?>
    this will give the value 3 i.e we are successful to get the value of $varname;

Similar Threads

  1. Dynamic variable names
    By scos in forum PHP Development
    Replies: 4
    Last Post: February 16th, 2004, 11:07 AM
  2. A variable $_POST variable?
    By CLuver in forum PHP Development
    Replies: 0
    Last Post: February 11th, 2004, 12:55 AM
  3. create variable names on the fly
    By sweetpotatoe in forum PHP Development
    Replies: 31
    Last Post: December 11th, 2003, 12:42 AM
  4. Can I use variable values as session names?
    By davidDuke in forum PHP Development
    Replies: 1
    Last Post: November 20th, 2003, 10:11 PM
  5. Replies: 5
    Last Post: November 16th, 2003, 11:31 AM

IMN logo majestic logo threadwatch logo seochat tools logo