如何向数组的键添加特殊字符

how can add special characters to keys of array

我想为数组的键添加特殊字符,就像这个例子。
我怎样才能转换这个数组

$tmp = array(
"name" => "aya",
"number" => "10");

$tmp = array(
"[name]" => "aya",
"[number]" => "10");  

您可以使用此代码:

foreach ($tmp as $key=> $value) {
    unset($tmp[$key]);
    $tmp["[$key]"] = $value;
}