Re: nested if in a for statement
| From: | Douglas Douglas | Date: | Tue, 17 Dec 2002 21:18:15 +0000 |
| Subject: | Re: nested if in a for statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128610@lists.php.net to get a copy of this message | ||
I think your error is this:
$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;
}
}
You're using eight variables, so $userVars have
indexes like these $userVars[0]=$nameFirst,
$userVars[1]=$nameLast, ... , $userVars[7]=$dob_day
In the for loop you're using $i <= count($userVars),
that is $i<=8, but you declare $i =0... so the loop is
running nine times 0,1,...,8
The echo that you're seeing is the last run, cause
empty($userVar[8]) is true (there is nothing in that
index) Got it?
Make it $i < count($userVars).
I hope this help you.
Douglas.
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com