
Untitled
By: a guest on
May 4th, 2012 | syntax:
None | size: 0.96 KB | hits: 6 | expires: Never
PHP array not outputting properly
$errors = array();
if (strlen($password) >= 6) {
array_push($errors, "Your password is not long enough! Must be over 6 characters!");
}
if(count($errors) !== 0) {
...
} else {
echo "There is errors<br/>";
foreach($errors as $er){
echo $er . "<br/>";
}
}
if(count($errors) === 0) {
// everything is okay
} else {
echo "There are errors<br/>";
foreach($errors as $er){
echo $er . "<br/>";
}
}
if (strlen($password) <= 6) {
if (strlen($password) < 6) {
array_push($errors, ...);
define('MIN_PASSWORD_LENGTH', 6);
// ...
if (strlen($password) < MIN_PASSWORD_LENGTH) {
array_push($errors, "Your password is not long enough!"
. " Must be over ".MIN_PASSWORD_LENGTH." characters!");
}
if(count($errors) >0) { //there are errors
echo "There is errors<br/>";
foreach($errors as $er){
echo $er . "<br/>";
}
}else{
//there are no errors
}