Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 0.96 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP array not outputting properly
  2. $errors = array();
  3.  
  4. if (strlen($password) >= 6) {
  5.     array_push($errors, "Your password is not long enough! Must be over 6 characters!");
  6. }
  7.  
  8. if(count($errors) !== 0) {
  9. ...
  10. } else {
  11.     echo "There is errors<br/>";
  12.     foreach($errors as $er){
  13.         echo $er . "<br/>";
  14.     }
  15. }
  16.        
  17. if(count($errors) === 0) {
  18.      // everything is okay
  19. } else {
  20.     echo "There are errors<br/>";
  21.     foreach($errors as $er){
  22.         echo $er . "<br/>";
  23.     }
  24. }
  25.        
  26. if (strlen($password) <= 6) {
  27.        
  28. if (strlen($password) < 6) {
  29.   array_push($errors, ...);
  30.        
  31. define('MIN_PASSWORD_LENGTH', 6);
  32.  
  33. // ...
  34.  
  35. if (strlen($password) < MIN_PASSWORD_LENGTH) {
  36.     array_push($errors, "Your password is not long enough!"
  37.       . " Must be over ".MIN_PASSWORD_LENGTH." characters!");
  38. }
  39.        
  40. if(count($errors) >0) {  //there are errors
  41.     echo "There is errors<br/>";
  42.     foreach($errors as $er){
  43.         echo $er . "<br/>";
  44.     }
  45. }else{
  46.     //there are no errors
  47. }