如何在PHP中将字符串(变量名)转换为变量


How to convert string (name of a variable) to a variable in PHP?

是否有可能使用字符串作为实际的变量名称?像这样:

$a = '$myvariable[''subitem'']';

如何转换变量$a以便实际使用变量

$myvariable['subitem'] ?

的例子:

$myvariable['subitem'] = "hello";
$a = '$myvariable[''subitem'']';
// do somenthing with $a
echo $a  // outputs "hello" instead of $myvariable['subitem']

这个怎么样:

$a = 'myvariable["subitem"]';
echo $$a;

以上是变量