RE: [PHP] stoping a while statement

From: Date: Wed, 10 Oct 2001 07:54:59 +0000
Subject: RE: [PHP] stoping a while statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70598@lists.php.net to get a copy of this message
It is always wiser explod()ing before loop starts. And, even so, the way he does has still a better solution: if(strstr($line, $var)) Then the sub loop can be completely avoided. Maxim Maletsky www.PHPBeginner.com > -----Original Message----- > From: _lallous [mailto:elias_bachaalany@yahoo.com] > Sent: mercoledì 10 ottobre 2001 10.48 > To: php-general@lists.php.net > Subject: Re: [PHP] stoping a while statement > > > Maxim, I guess he can't get his array as you suggested...as > it seems he's reading that value from a file and then he's > exploding it.... > > "Maxim Maletsky )" <php-general@phpbeginner.com> wrote in > message news:000c01c1515f$8fbdad00$9828abd4@tatiana... > > > > > > You need > > > > Break; > > > > > > And, lert me suggest you: > > > > Hyave your $i this way: > > > > $i[] = ''www.northwesthost.com'; > > $i[] = 'dns1.northwesthost.com'; > > $i[] = 'dns2.northwesthost.com'; > > $i[] = 'www.testr.com'; > > > > foreach($i as $key=>$value) { > > .... > > if(Condition) > > Break; // stops here > > } > > > > > > Maxim Maletsky > > www.PHPBeginner.com > > > > > > > > > > > > > -----Original Message----- > > > From: Richard Kurth [mailto:rkurth@pacifier.com] > > > Sent: mercoledi 10 ottobre 2001 9.24 > > > To: Richard Kurth > > > Subject: [PHP] stoping a while statement > > > > > > > > > > > > What do I need in the While statement so it will stop > when it gets > > > to the end of the $i variable. > > > > > > > > > > > > $variable="www.tester.com"; > > > $i="www.northwesthost.com,dns1.northwesthost.com,dns2.northwes > > > thost.com,www.tester.com"; > > > > > > $count = 0; > > > while($i ==true) { <--what do I need hear so it will stop > > > $line_text =$i; > > > $strings = explode(",", $line_text); > > > if ($variable == trim($strings[$count])) { > > > print("<b> Domain $variable is already > > > there</b><br>"); > > > break; > > > } > > > ++$count; > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Best regards, > > > Richard > > > mailto:rkurth@pacifier.com > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: > php-general-help@lists.php.net To > > > contact the list administrators, e-mail: > > > php-list-admin@lists.php.net > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: > php-general-help@lists.php.net To contact the list > administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#70598) next »