Reputation: 2586
My array looks like this :-
[data] => Array
(
[3] => Array
(
[0] => ind_ava_1
[1] => ind_ava_2
)
[5] => Array
(
[0] => varejo_bens_1
[1] => varejo_bens_2
[2] => varejo_bens_3
)
[20] => Array
(
[1] => fun_t1_2
[2] => fun_t1_3
[3] => fun_t1_4
)
[22] => Array
(
[1] => mar_ven_2
)
[24] => Array
(
[0] => op_oper_1
[1] => op_oper_2
)
[26] => Array
(
[1] => op_org_2
[2] => op_org_3
)
[28] => Array
(
[1] => op_risco_2
)
[30] => Array
(
[0] => op_est_1
)
)
I want to remove every cell in it, as in remove [3], [5], etc etc. and make it empty before filling it up again. Any idea how I can do that?
I tried following:
for($ctr = 0; $ctr < count($array); $ctr++) {
unset(data[$array]);
}
Upvotes: 0
Views: 35
Reputation: 9488
You are trying to run a function on something that doesn't exist. data[$array]
is not a thing.
Assuming your array is called $array
you can do unset($array['data']);
and you don't need to run this in a loop.
PauloASilva's answer should work too.
Upvotes: 1