我在想是否有方法可以解决这个问题(或者这个问题是否能够被解决)。
我有一段类似于这样的代码。我有一个字符串,其中包含方括号,类似于访问数组键时使用的方括号。我想通过使用该字符串的值来创建该数组键本身。我希望这段代码能更好地解释我的意思。
// String that has a value similar to an array key
$string = 'welcome["hello"]';
$$string = 'thisworks';
// I could then print the array keys value like this
print( $welcome["hello"] );
// This would hopefully output 'thisworks'.
然而似乎无法使其正常工作,这是否可能(或者还有其他方法可以解决)?