RE: [PHP] Problem with header in an if SOLVED

From: Date: Fri, 25 Mar 2005 16:52:28 +0000
Subject: RE: [PHP] Problem with header in an if SOLVED
Groups: php.general 
Request: Send a blank email to php-general+get-211582@lists.php.net to get a copy of this message
[snip] /* check for errors */ $arrCheckItems = array( 'Name', 'Dept', 'Level', ); /* check for blanks */ foreach($_POST AS $key=>$value){ if(in_array(niceName($key), $arrCheckItems)){ $errorsReported[] = notBlank($key, $value); } } Even if the return from notBlank is nothing, $errorReported[] gets set for each item passed in the foreach loop. I have tried using conditional returns in the function, but to no avail. Perhaps my logic is screwed on this. [/snip] I changed to the following code and it solves the problem ... foreach($_POST AS $key=>$value){ if(in_array(niceName($key), $arrCheckItems)){ $nbr = notBlank($key, $value); if(!('' == $nbr)){ $errorsReported[] = $nbr; } } } Before I was directly assigning the value of the return from the notBlank function to $errorsReported. Now something only gets assigned to $errorsReported if there is something to assign.

« previous php.general (#211582) next »