Is using a foreach safe to do or does this open up for more security leaks?
<?php
foreach ($_POST as $key=>$value){
$_POST[$key] = htmlspecialchars($_POST[$key]);
}
?>
<form method="POST" action="">
<input type="text" name="test" value="<?=isset($_POST['test'])?$_POST['test']:''?>"/>
<input type="submit" />
</form>
VS.
<?php
$_POST['test'] = htmlspecialchars($_POST['test']);
?>
<form method="POST" action="">
<input type="text" name="test" value="<?=isset($_POST['test'])?$_POST['test']:''?>"/>
<input type="submit" />
</form>