I want add special character to keys of my array, like this example.
how can i convert this array
$tmp = array(
"name" => "aya",
"number" => "10");
to
$tmp = array(
"[name]" => "aya",
"[number]" => "10");
I want add special character to keys of my array, like this example.
how can i convert this array
$tmp = array(
"name" => "aya",
"number" => "10");
to
$tmp = array(
"[name]" => "aya",
"[number]" => "10");
You can use this code:
foreach ($tmp as $key=> $value) {
unset($tmp[$key]);
$tmp["[$key]"] = $value;
}