Depends on what result exactly you want to achieve. Do you want to remove just the value of the "answer" key, replace the value with a different value, or remove the key entirely?
I'll be using the following simplified data structure for demonstration purposes:
php > $a = Array("a" => Array("b" => 2, "c" => Array("d" => 4, "e" => 5)));
php > print_r($a);
Array
(
[a] => Array
(
[b] => 2
[c] => Array
(
[d] => 4
[e] => 5
)
)
)
To remove just the value of the (sub)key "c" you'd assign NULL
to the key:
php > $a['a']['c'] = NULL;
php > print_r($a);
Array
(
[a] => Array
(
[b] => 2
[c] =>
)
)
Similarly you'd assign the new value if you wanted to replace the current value:
php > $a['a']['c'] = Array("x" => "foo", "y" => "bar");
php > print_r($a);
Array
(
[a] => Array
(
[b] => 2
[c] => Array
(
[x] => foo
[y] => bar
)
)
)
If you want to remove the key entirely you'd use the unset()
function, as you've already discovered:
php > unset($a['a']['c']);
php > print_r($a);
Array
(
[a] => Array
(
[b] => 2
)
)