Page 1 of 1

exit loop

Posted: Wed Feb 09, 2005 8:53 pm
by shiznatix
i was wonder if there was a way to exit a for loop after one variable is equal to the other, i want the script to continue but i just want the loop to stop right there and then go to the next part of the script.

example:

Code: Select all

$arrview = explode(",", $notviewd);
		$countview = count($arrview);
		for ($i=0; $i<$countview; $i++)&#123;
		echo $arrview&#1111;$i].' ';
			if ($arrview&#1111;$i] == $threadid)&#123;
				if ($reply_count > '9')&#123;
				echo "<img src='img/new_post_hot.gif'>";
      //exit loop here
				&#125;
				if($accesslvl == '1')&#123;
				echo "<img src='img/new_post_lock.gif'>";
      //exit loop here
				&#125;
				if($reply_count < '9')&#123;
				echo "<img src='img/new_post.gif'>";
      //exit loop here
				&#125;
			&#125;
		&#125;

Posted: Wed Feb 09, 2005 8:54 pm
by feyd
break;

:roll:

since you'll probably ask later: continue;

you'll understand when you come to the question :)

Posted: Wed Feb 09, 2005 8:57 pm
by shiznatix
affirmative, thanks

Posted: Wed Feb 09, 2005 10:09 pm
by thegreatone2176
or you could put

$i=$countview;

then it wouldnt loop anymore