我想在我的数组的键中添加特殊字符,就像这个例子一样 我怎么能转换这个数组
$tmp = array(
"name" => "aya",
"number" => "10");
到
$tmp = array(
"[name]" => "aya",
"[number]" => "10");
答案 0 :(得分:1)
您可以使用此代码:
foreach ($tmp as $key=> $value) {
unset($tmp[$key]);
$tmp["[$key]"] = $value;
}