Page 1 of 1

Concatenation

Posted: Fri Sep 06, 2002 8:39 am
by Johnm
I need to concatenate this into a variable... any ideas as to how?
Here is the scenario:
The end var name needs to be

Code: Select all

$n_unit1_length
if the current base number is unit 1.
The current base number is determined by a var that is passed through the header called $base_number, in this case $base_number is 1
so here is the general idea but it gives a parse error. I understand why but I do not know how to correct it.

Code: Select all

eval("$n_unit".$base_number."_length")
another var gets set to this so in the end it needs to look something like this:

Code: Select all

$m_pan_center=eval("$n_unit".$base_number."_length")
Direwolf

Posted: Fri Sep 06, 2002 3:31 pm
by hob_goblin
simple: variable variables

Code: Select all

$foo = "foooobar";
$foobar = "OKAY!";
$thing = "bar";

echo $foo{$thing};
should work? no?

http://www.php.net/manual/en/language.v ... riable.php