RE: [PHP] nested if in a for statement

From: Date: Tue, 17 Dec 2002 21:53:07 +0000
Subject: RE: [PHP] nested if in a for statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-128620@lists.php.net to get a copy of this message
I just took the code and changed it to check two values, both of the values are there but it returned the message, I put in some prints and it appears it failed on '2' having only two values to check, 0 and 1, I would say it is doing another check after it has exceeded the number of variables and this is causing it to pass. -----Original Message----- From: Tim Ward [mailto:timward@chessish.com] Sent: Tuesday, December 17, 2002 4:14 PM To: James Brennan; php-general@lists.php.net Subject: Re: [PHP] nested if in a for statement looks ok as long as you are really testing what you mean to. As you've written it if any of the variables are an empty string, zero, logical false or not set then the if statement will be true. what is $auth? Tim Ward http://www.chessish.com mailto:timward@chessish.com ----- Original Message ----- From: James Brennan <loopjunkie@hotmail.com> To: <php-general@lists.php.net> Sent: Tuesday, December 17, 2002 9:03 PM Subject: [PHP] nested if in a for statement > I am checking the values of a submited forms for empty fields with the code > below. My problem is that the echo statement is being executed once > regardless of whether or not the if statement is true. What am I missing? > > thanks, > loopjunkie > > ---- snip ---- > /* variables in array set earlier in script */ > $userVars = array($nameFirst, $nameLast, $pass, $pass2, $auth, $dob_year, > $dob_month, $dob_day); > > for ($i=0; $i <= count($userVars); $i++) { > if (empty($userVars[$i])) { > echo "please enter all required info"; > break; > } > } > --- snip ---- > > > _________________________________________________________________ > Add photos to your messages with MSN 8. Get 2 months FREE*. > http://join.msn.com/?page=features/featuredemail > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#128620) next »