Appending a value of a variable to a variable name? [duplicate]
Possible Duplicate:
Can I use a generated variable name in PHP?
Am stuck here!
$part_one = "abc";
$v = "one";
echo $part_???; // should output "abc"
How do I modify ??? to reference $v?
Thanks!
You need variable variables:
echo ${'part_'.$v};
// or
$var = 'part_'.$v;
echo $$var;
$_part$v;? maybe idk. I know you can do this:
$vname="variable";
$$vname="hello";
echo $variable;
//WOULD output "hello"
try this:
$name="_part";
$name=$name . $v;
$$name=$value;
精彩评论