December 14th, 1999, 06:02 PM
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?
December 15th, 1999, 07:51 AM
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:
// Outputs: "variable_value"
Is this what you meant?
[This message has been edited by PAV (edited 12-15-99).]
December 15th, 1999, 12:59 PM
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;