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.
$_POSTis just another variable, except it has (super)global scope.…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.