1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Is there in PHP a way to create symbolic references when it comes to variable names? I am trying to define a variable using another variable as a part of the variable name. Something like:

    $string$another_var = "variable value"

    It can be done in practically any language, can it be done in PHP?

  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    You can try it with variable variables:

    // give $another_var value of "stringanother_var"
    $another_var = "string" . "another_var";

    // Parse this value as name of a variable and give it a value as:

    $$another_var = "variable value";

    //if you then call:

    echo $stringanother_var;

    // Outputs: "variable_value"

    Is this what you meant?

    Regards, Peter

    [This message has been edited by PAV (edited 12-15-99).]
  4. #3
  5. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Maybe you want to try something like evaluate:

    $x = 321;
    eval('$name = $file'.$x.'_name;');

    This will result in the same code as:
    $name = $file321_name;

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. Replies: 4
    Last Post: January 28th, 2004, 08:29 AM
  3. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 01:14 PM
  4. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 03:12 PM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 01:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo