<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Quinterox &#187; break</title>
	<atom:link href="http://www.quinterox.com/content/tag/break/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quinterox.com/content</link>
	<description>Cesar Quinteros</description>
	<lastBuildDate>Sun, 20 Jun 2010 04:51:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Loops: break &amp; continue statements</title>
		<link>http://www.quinterox.com/content/code/loops-break-continue-statements/</link>
		<comments>http://www.quinterox.com/content/code/loops-break-continue-statements/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 18:05:45 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[break]]></category>
		<category><![CDATA[continue]]></category>
		<category><![CDATA[loops]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=19</guid>
		<description><![CDATA[Simple and easy to understand explanations of loop, break, and continue statements.]]></description>
			<content:encoded><![CDATA[<h3>Break</h3>
<p>Loops are very useful to help sift through information for what you need. However once you find your data you probably would like your loop to stop. For that you would have to use the BREAK statement.<br />
In this case the BREAK statement was used to not generate a division by zero warning. Watch as the code is stopped right before division by zero occurs.</p>
<pre>&lt;?php
$count = -10;
for (;$count &lt;= 10; $count++) {
     if ($count == 0) {
     break;
     } else {
             $result = 200/$count;
             echo "200 divided by $count is $result&lt;br /&gt;";
     }
}
?&gt;</pre>
<p><strong>Results: </strong><br />
200 divided by -10 is -20<br />
200 divided by -9 is -22.222222222222<br />
200 divided by -8 is -25<br />
200 divided by -7 is -28.571428571429<br />
200 divided by -6 is -33.333333333333<br />
200 divided by -5 is -40<br />
200 divided by -4 is  -50<br />
200 divided by -3 is -66.666666666667<br />
200 divided by -2 is -100<br />
200 divided by -1 is -200</p>
<h3>Continue</h3>
<p>The continue statement ends the execution of the current code lap but doesn&#8217;t stop the whole loop from continuing.</p>
<p>The following code, similar to the break, will stop the code from dividing by zero but continue afterwards.</p>
<pre>&lt;?php
$count = -10;
for (;$count &lt;= 10; $count++) {
     if ($count == 0) {
     continue;
     } else {
             $result = 200/$count;
             echo "200 divided by $count is $result&lt;br /&gt;";
     }
}
?&gt;</pre>
<p><strong>Results:</strong><br />
200 divided by -10 is -20<br />
200 divided by -9 is -22.222222222222<br />
200 divided by -8 is -25<br />
200 divided by -7 is -28.571428571429<br />
200 divided by -6 is -33.333333333333<br />
200 divided by -5 is -40<br />
200 divided by -4 is -50<br />
200 divided by -3 is -66.666666666667<br />
200 divided by -2 is -100<br />
200 divided by -1 is -200<br />
200 divided by 1 is 200<br />
200 divided by 2 is 100<br />
200 divided by 3 is 66.666666666667<br />
200 divided by 4 is 50<br />
200 divided by 5 is 40<br />
200 divided by 6 is 33.333333333333<br />
200 divided by 7 is 28.571428571429<br />
200 divided by 8 is 25<br />
200 divided by 9 is 22.222222222222<br />
200 divided by 10 is 20</p>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/loops-break-continue-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
