note 30409 added to function.array-sum

From: Date: Mon, 17 Mar 2003 15:22:08 +0000
Subject: note 30409 added to function.array-sum
Groups: php.notes 
Request: Send a blank email to php-notes+get-45416@lists.php.net to get a copy of this message
A practical implementation of this function: creating a standardised error-checking process. // check some fields if(strlen(trim($username))<3){ $errormessage[]="You need to enter a username"; }else{ $errormessage[]=0; } if(strlen(trim($password))<3){ $errormessage[]="You need to enter a password"; }else{ $errormessage[]=0; } // check to see if there were any errors (an error-free submission will have a sum of 0) if(array_sum($errormessage)!=0){ print "error!"; // (I use a separate error display function) }else{ // no errors found, proceed with submission } -- http://www.php.net/manual/en/function.array-sum.php http://master.php.net/manage/user-notes.php?action=edit+30409 http://master.php.net/manage/user-notes.php?action=delete+30409 http://master.php.net/manage/user-notes.php?action=reject+30409

« previous php.notes (#45416) next »