{"id":6574,"date":"2021-06-28T12:36:38","date_gmt":"2021-06-28T12:36:38","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=6574"},"modified":"2022-04-13T16:33:33","modified_gmt":"2022-04-13T16:33:33","slug":"define-what-is-loop-and-what-are-the-types-with-syntax","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/","title":{"rendered":"Define What is Loop and what are the Types with Syntax."},"content":{"rendered":"\n<p class=\"wp-block-paragraph\" id=\"41cb\">In this tutorial i\u2019m going to define what is loop and what are the types with syntax with examples.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"9608\"><strong>What is Loop?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"f1ae\">Any Repeated task more than one time that is called Loop. In a loop structure, the loop asks a question. If the answer requires action, it is executed. Using loops in computer programs simplifies rather optimizes the process of coding.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"78db\">Types of Loops?<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>While Loop.<\/li><li>Do while Loop<\/li><li>For Loop<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"7e26\">While Loop:- While loop is a pre-test loop. It first test a specified conditional expression and as long as the condition true action taken. While loop also known as Entry Control Loop<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"7ca1\">Syntax with example:-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br><br>$am =1;<br><br>while($am&lt;=6;<br>    {<br>        echo \"this is while condition: $am &lt;br \/&gt;\";<br>        $am++;<br>    }<br>?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"ddd7\">OutPut \ud83d\udc47<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/591\/1*s9hlSfFyyUWBs7wmYP7y1w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"47f1\">2. Do while Loop:- Do while loop is similar to while loop but the condition is checked after the loop. This ensure that the loop body is run at least once.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br><br>$ami = 3;<br><br>    do{<br>        echo \"this is Laravel Amit: $ami &lt;br \/&gt;\";<br>        $ami++;<br><br>    }while($ami&lt;=6);<br><br>?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"6a3c\">OutPut \ud83d\udc47<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/proxy\/1*gjsl1By1EwueW-U_S9rZmQ.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"d488\">3. For Loop :- The for is frequently used usullay where the loop will be traversed a fixed numbers of times. A loop variable is used to control the loop<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"a98b\">Syntax + example:-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br><br>   for($num=1; $num&lt;=5; $num++)<br>   {<br>       echo \"this is for loop: $num &lt;br \/&gt;\";<br>   }<br><br>?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"c66b\">OutPut \ud83d\udc47<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/635\/1*q2Efsx_XZxJ11DnP0zvk1Q.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"cf78\">Thanks \u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial i\u2019m going to define what is loop and what are the types with syntax with examples. What [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6575,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5388],"tags":[5409,5401,177,5208,5408],"class_list":["post-6574","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-forloop","tag-loop","tag-php","tag-php-framework","tag-whileloop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Define What is Loop and what are the Types with Syntax. - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Define What is Loop and what are the Types with Syntax. - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"In this tutorial i\u2019m going to define what is loop and what are the types with syntax with examples. What [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-28T12:36:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-13T16:33:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/06\/define-loop-with-syntax-and-example.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"315\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"rajeshkumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rajeshkumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/\"},\"author\":{\"name\":\"rajeshkumar\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"headline\":\"Define What is Loop and what are the Types with Syntax.\",\"datePublished\":\"2021-06-28T12:36:38+00:00\",\"dateModified\":\"2022-04-13T16:33:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/\"},\"wordCount\":188,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/define-loop-with-syntax-and-example.png\",\"keywords\":[\"forloop\",\"loop\",\"Php\",\"php framework\",\"whileloop\"],\"articleSection\":[\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/\",\"name\":\"Define What is Loop and what are the Types with Syntax. - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/define-loop-with-syntax-and-example.png\",\"datePublished\":\"2021-06-28T12:36:38+00:00\",\"dateModified\":\"2022-04-13T16:33:33+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/define-loop-with-syntax-and-example.png\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/define-loop-with-syntax-and-example.png\",\"width\":600,\"height\":315},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/define-what-is-loop-and-what-are-the-types-with-syntax\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Define What is Loop and what are the Types with Syntax.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\",\"name\":\"rajeshkumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"caption\":\"rajeshkumar\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/rajeshkumar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Define What is Loop and what are the Types with Syntax. - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/","og_locale":"en_US","og_type":"article","og_title":"Define What is Loop and what are the Types with Syntax. - scmGalaxy","og_description":"In this tutorial i\u2019m going to define what is loop and what are the types with syntax with examples. What [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/","og_site_name":"scmGalaxy","article_published_time":"2021-06-28T12:36:38+00:00","article_modified_time":"2022-04-13T16:33:33+00:00","og_image":[{"width":600,"height":315,"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/06\/define-loop-with-syntax-and-example.png","type":"image\/png"}],"author":"rajeshkumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rajeshkumar","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/"},"author":{"name":"rajeshkumar","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"headline":"Define What is Loop and what are the Types with Syntax.","datePublished":"2021-06-28T12:36:38+00:00","dateModified":"2022-04-13T16:33:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/"},"wordCount":188,"commentCount":0,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/06\/define-loop-with-syntax-and-example.png","keywords":["forloop","loop","Php","php framework","whileloop"],"articleSection":["php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/","name":"Define What is Loop and what are the Types with Syntax. - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/06\/define-loop-with-syntax-and-example.png","datePublished":"2021-06-28T12:36:38+00:00","dateModified":"2022-04-13T16:33:33+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/06\/define-loop-with-syntax-and-example.png","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/06\/define-loop-with-syntax-and-example.png","width":600,"height":315},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/define-what-is-loop-and-what-are-the-types-with-syntax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Define What is Loop and what are the Types with Syntax."}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361","name":"rajeshkumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","caption":"rajeshkumar"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/rajeshkumar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/6574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=6574"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/6574\/revisions"}],"predecessor-version":[{"id":6576,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/6574\/revisions\/6576"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media\/6575"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=6574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=6574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=6574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}