Concatenation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Concatenation

Post 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
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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
Post Reply