如何在PHP中将字符串设置为文字变量?基本上我有一个类似的数组
$data['setting'] = "thevalue";
Run Code Online (Sandbox Code Playgroud)
我想将其转换'setting'到$setting使$setting成为"thevalue".
谢谢你的帮助!
请参阅PHP变量变量.
你的问题不是很清楚,但也许你想要这样的东西:
//Takes an associative array and creates variables named after
//its keys
foreach ($data as $key => $value) {
$$key = $value;
}
Run Code Online (Sandbox Code Playgroud)