<?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>while loop in php - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/while-loop-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/while-loop-in-php/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 01 Aug 2022 08:49:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>while loop in php - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/while-loop-in-php/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What are the different loops in PHP ?</title>
		<link>https://www.wikitechy.com/interview-questions/php/what-are-the-different-loops-in-php/</link>
					<comments>https://www.wikitechy.com/interview-questions/php/what-are-the-different-loops-in-php/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Mon, 01 Aug 2022 08:43:27 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[do loop in php]]></category>
		<category><![CDATA[foreach loop in php]]></category>
		<category><![CDATA[how many loops in php]]></category>
		<category><![CDATA[how many types of loops are supported in php]]></category>
		<category><![CDATA[how many types of loops are there in php]]></category>
		<category><![CDATA[loop in php]]></category>
		<category><![CDATA[php loop array]]></category>
		<category><![CDATA[php while loop multiple conditions]]></category>
		<category><![CDATA[print 1 to 10 using for loop in php]]></category>
		<category><![CDATA[what are the different loops in php]]></category>
		<category><![CDATA[what is loops in php]]></category>
		<category><![CDATA[while loop in php]]></category>
		<category><![CDATA[while loop in php mysql]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4528</guid>

					<description><![CDATA[Like any other language, in PHP loop is used to execute a statement or a block of statements, multiple times until and unless a specific condition is met. Loops helps the user to save both effort and time of writing the same code multiple times. PHP supports four types of looping techniques, they are: For [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li>Like any other language, in PHP loop is used to execute a statement or a block of statements, multiple times until and unless a specific condition is met.</li>
<li>Loops helps the user to save both effort and time of writing the same code multiple times.</li>
<li>PHP supports four types of looping techniques, they are:</li>
</ul>
<ol>
<li style="list-style-type: none;">
<ol>
<li>For loop</li>
<li>While loop</li>
<li>Do-while loop</li>
<li>Foreach loop</li>
</ol>
</li>
</ol>
<h2 id="for-loop">For loop</h2>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-4531 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/for-loop.png" alt="" width="725" height="625" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/for-loop.png 725w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/for-loop-300x259.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/for-loop-390x336.png 390w" sizes="(max-width: 725px) 100vw, 725px" /></p>
<ul>
<li>For loop is used when the user knows in advance, how many times the block needs to execute.</li>
<li>The number of iterations is known beforehand and these types of loops are also known as entry-controlled loops.</li>
<li>Initialization expression, test expression, update expression are the three main parameters to the code.</li>
</ul>
<h3 id="syntax">Syntax</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">for (initialization expression; test condition; update expression) {<br/>          // code to be executed<br/>        }</code></pre> </div>
<h2 id="while-loop">While loop</h2>
<p><img decoding="async" class="alignnone size-full wp-image-4532" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/while-loop.png" alt="" width="728" height="633" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/while-loop.png 728w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/while-loop-300x261.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/while-loop-390x339.png 390w" sizes="(max-width: 728px) 100vw, 728px" /></p>
<ul>
<li>While loop is also an entry control loop like for loop condition.</li>
<li>First it checks the condition at the start of the loop and if its true then it enters the loop and executes the block of statements, and goes on executing it as long as the condition holds true.</li>
</ul>
<h3 id="syntax-2"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">             while (if the condition is true) {<br/>              // code is executed<br/>         }</code></pre> </div>
<h2 id="do-while-loop">Do-while loop</h2>
<p><img decoding="async" class="alignnone size-full wp-image-4533" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/do-while.png" alt="" width="719" height="633" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/do-while.png 719w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/do-while-300x264.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/do-while-390x343.png 390w" sizes="(max-width: 719px) 100vw, 719px" /></p>
<ul>
<li>Do while loop is an exit control loop which means that it first enters the loop, executes the statements, and then checks the condition.</li>
<li>Using do-while a statement is executed at least once.</li>
<li>The program is executed as long as the condition holds true, after executing once.</li>
</ul>
<h3 id="syntax-3"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">do {<br/><br/>               //code is executed<br/><br/>         } while (if condition is true);</code></pre> </div>
<h2 id="foreach-loop">Foreach loop</h2>
<ul>
<li>Foreach loop is used to iterate over arrays and for every counter of loop, an array element is assigned and the next counter is shifted to the next element.</li>
</ul>
<h3 id="syntax-4"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">foreach (array_element as value) {<br/>         //code to be executed<br/>       }</code></pre> </div>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/php/what-are-the-different-loops-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
