php字符串名称作为变量

Pai*_*sal 4 php


$string = "id";

want result to be like 

$id = "new value";

我如何在PHP中编码?

编辑..

下面怎么样?


$column = array("id","name","value");

let say found 3 row from mysql

want result to be like this

$id[0] = "3";
$id[1] = "6";
$id[2] = "10";

$name[0] = "a";
$name[1] = "b";
$name[2] = "c";

$value[0] = "bat";
$value[1] = "rat";
$value[2] = "cat";


Rob*_*itt 8

Theres 2主要方法

第一个是双$(变量变量),就像这样

$var = "hello";
$$var = "world";
echo $hello; //world

//You can even add more Dollar Signs

$Bar = "a";
$Foo = "Bar";
$World = "Foo";
$Hello = "World";
$a = "Hello";

$a; //Returns Hello
$$a; //Returns World
$$$a; //Returns Foo
$$$$a; //Returns Bar
$$$$$a; //Returns a

$$$$$$a; //Returns Hello
$$$$$$$a; //Returns World

//... and so on ...//
Run Code Online (Sandbox Code Playgroud)

@资源

第二种方法是使用{}这样的

$var = "hello";
${$var} = "world";
echo $hello;
Run Code Online (Sandbox Code Playgroud)

你也可以这样做:

${"this is a test"} = "works";
echo ${"this is a test"}; //Works
Run Code Online (Sandbox Code Playgroud)

几个星期前,我在流线型对象上玩了一个关于这个的游戏,得到了一些有趣的结果

$Database->Select->{"user id"}->From->Users->Where->User_id($id)->And->{"something > 23"};
Run Code Online (Sandbox Code Playgroud)