I want clear $_POST array content fully, all examples what I see in internet, looks like this:
if (count($_POST) > 0) { foreach ($_POST as $k=>$v) { unset($_POST[$k]); } }
Tell please, this variant will be not more better? (Point of view as saving resources)
if (count($_POST) > 0) { $_POST = array(); }
or not ?
Yes, that is fine. $_POST
is just another variable, except it has (super)global scope.
$_POST = array();
...will be quite enough. The loop is useless. It's probably best to keep it as an array rather than unset it, in case other files are attempting to read it and assuming it is an array.
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