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 ?
IF you want to do this using loop then use for loop. Show activity on this post. You have to use for loop for this. you can use foreach loop but it will not unset all variable one variable still remains.
unset() destroys the specified variables. The behavior of unset() inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is unset() inside of a function, only the local variable is destroyed.
Using unset() Function: The unset() function is used to remove element from the array. The unset function is used to destroy any other variable and same way use to delete any element of an array. This unset command takes the array key as input and removed that element from the array.
try this
unset($foo1, $foo2, $foo3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With