Re: Array Elements & While Loops
| From: | Tom Churm | Date: | Mon, 01 Oct 2001 12:28:47 +0000 |
| Subject: | Re: Array Elements & While Loops | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69447@lists.php.net to get a copy of this message | ||
hi, _lallous:
i've tried it with "==" and it still doesn't work: code for the valid
variables is executed before my die() function is called.
thanks, though,
tom
_lallous wrote:
>
> > if ($flag = 1) {
> > die ("<p align='center'><b>Email #$errorNo is not a valid
> > e-mail
>
> should be:
>
> if ($flag == 1) // notice the double-equal signs
>
> "Tom Churm" <thomas.churm@pixelpark.com> wrote in message
> news:3BB85BC2.F2177483@pixelpark.com...
> > hi,
> >
> > my problem is this: i'm using a while loop to check elements in an
> > Array for valid email syntax. if $User[0] is a valid email address but
> > $User[1] is not, the code for $User[0] is still executed before the die
> > statement. i need my loop to finish checking ALL array elements for
> > validity, and to then die BEFORE any further code is executed. here's
> > what i have now (it doesn't work):
> >
> > //loop to check for bad email addresses:
> > $j = 0;
> > $flag = 0;
> > while ($j < count($User)){
> > if
> >
>
> (($User[$j]!="")&&!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-
> ]+)*$",
> > $User[$j]))
> > {
> > $flag = 1;
> > $errorNo = $j + 1;
> > }
> > //die if flag is 1
> > if ($flag = 1) {
> > die ("<p align='center'><b>Email #$errorNo is not a valid
> > e-mail
> > address!</b><br><br><br><a
> > href='javascript:window.history.back();'>Please return and correct
> > this.</a></p>");
> > }
> > else {
> > continue...
> > }
> >
> > any suggestions would be great!
> >
> > thanks much,
> >
> > tom