Possible Duplicate:
Can you unset() many variables at once in PHP?
I have 3 variables var1
var2
var3
. Is there's a way of un-setting them without repeated use of unset()
function ?
Possible Duplicate:
Can you unset() many variables at once in PHP?
I have 3 variables var1
var2
var3
. Is there's a way of un-setting them without repeated use of unset()
function ?
Don't use foreach
loop for this. Since it works with a copy of array.
See Example
IF you want to do this using loop then use for
loop.
use like this
for($i=0 ; $i<count($array) ; $i++)
{
unset($array[$i]);
}
You have to use for
loop for this.
you can use foreach
loop but it will not unset all variable one variable still remains.
foreach($array as $arr)
{
unset($array[$arr]);
}