you rewrite the array before exiting.
$errors = array();
foreach ($errors as $error)
delete $errors = array()and it should work.
It would be cleaner to initialize $errors = array()at the very beginning of the script, and then check count($errors) > 0instead empty:
if (count($errors) == 0)
{
}
else
{
$errors = array();
foreach ($errors as $error)
echo '<li>'.$error.'</li>';
}
this way you will avoid notifications about $errorwhich will not be set.
source
share