$string = "id";
want result to be like
$id = "new value";
如何在PHP中對此進行編碼?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";
雖然PHP也允許你這樣做(如下顯示的答案)它通常被認爲是一個糟糕的設計原則,它會讓你的代碼難以維護。更好的方法可能是使用關聯數組,例如`$ my_array ['id'] =「new value」;` – Gareth 2011-01-11 10:47:16
您將不得不爲更新創建一個單獨的問題。 – RobertPitt 2011-01-11 11:41:16