PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Feb 09, 2005 8:53 pm
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++){
echo $arrviewї$i].' ';
if ($arrviewї$i] == $threadid){
if ($reply_count > '9'){
echo "<img src='img/new_post_hot.gif'>";
//exit loop here
}
if($accesslvl == '1'){
echo "<img src='img/new_post_lock.gif'>";
//exit loop here
}
if($reply_count < '9'){
echo "<img src='img/new_post.gif'>";
//exit loop here
}
}
}
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Feb 09, 2005 8:54 pm
break;
since you'll probably ask later: continue;
you'll understand when you come to the question
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Feb 09, 2005 8:57 pm
affirmative, thanks
thegreatone2176
Forum Contributor
Posts: 102 Joined: Sun Jul 11, 2004 1:27 pm
Post
by thegreatone2176 » Wed Feb 09, 2005 10:09 pm
or you could put
$i=$countview;
then it wouldnt loop anymore