{"id":82,"date":"2026-05-20T09:11:53","date_gmt":"2026-05-20T09:11:53","guid":{"rendered":"https:\/\/gigz.pk\/php\/?post_type=lesson&#038;p=82"},"modified":"2026-05-21T14:38:29","modified_gmt":"2026-05-21T14:38:29","slug":"break-and-continue","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/php\/?lesson=break-and-continue","title":{"rendered":"break and continue"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In PHP and many other programming languages, loops are used to repeat a block of code multiple times. Sometimes, we need more control over how a loop behaves. This is where the break and continue statements are used. They help control the flow of loops based on specific conditions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Break Statement<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The break statement is used to completely stop a loop before it finishes its full cycle. When break is executed, the loop ends immediately and the program moves to the next statement outside the loop.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example of Break Statement<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>for ($i = 1; $i &lt;= 10; $i++) {<br>    if ($i == 5) {<br>        break;<br>    }<br>    echo $i;<br>}<br>?&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, the loop stops when the value of i becomes 5.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Continue Statement<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The continue statement is used to skip the current iteration of a loop and move to the next iteration. It does not stop the loop completely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example of Continue Statement<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>for ($i = 1; $i &lt;= 10; $i++) {<br>    if ($i == 5) {<br>        continue;<br>    }<br>    echo $i;<br>}<br>?&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, the number 5 is skipped, but the loop continues until 10.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Difference Between Break and Continue<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Break stops the entire loop immediately<br>Continue skips only one iteration and continues the loop<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Real World Use of Break and Continue<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Break is used when a condition is met and further looping is unnecessary such as searching for a value and stopping when found<br>Continue is used when certain values need to be ignored such as skipping invalid or unwanted data in a list<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Advantages of Break and Continue<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">They improve control over loops<br>They make code more efficient<br>They help handle conditions more cleanly<br>They reduce unnecessary processing<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Break and continue are powerful loop control tools in PHP. They help developers manage loop execution more efficiently and build smarter logic in programs.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/php\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PHP Fundamentals (Beginner Level) > Loops > break and continue<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1779268158252\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":19,"template":"","class_list":["post-82","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>break and continue - Learn PHP with GiGz.PK<\/title>\n<meta name=\"description\" content=\"Learn PHP break and continue statements with examples. Understand loop control, skipping iterations, and stopping loops easily.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/php\/?lesson=break-and-continue\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"break and continue - Learn PHP with GiGz.PK\" \/>\n<meta property=\"og:description\" content=\"Learn PHP break and continue statements with examples. Understand loop control, skipping iterations, and stopping loops easily.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/php\/?lesson=break-and-continue\" \/>\n<meta property=\"og:site_name\" content=\"Learn PHP with GiGz.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-21T14:38:29+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=break-and-continue\",\"url\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=break-and-continue\",\"name\":\"break and continue - Learn PHP with GiGz.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/#website\"},\"datePublished\":\"2026-05-20T09:11:53+00:00\",\"dateModified\":\"2026-05-21T14:38:29+00:00\",\"description\":\"Learn PHP break and continue statements with examples. Understand loop control, skipping iterations, and stopping loops easily.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=break-and-continue#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=break-and-continue\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=break-and-continue#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/php\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP Fundamentals (Beginner Level) > Loops > break and continue\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/php\\\/\",\"name\":\"Learn PHP with GiGz.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"break and continue - Learn PHP with GiGz.PK","description":"Learn PHP break and continue statements with examples. Understand loop control, skipping iterations, and stopping loops easily.","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:\/\/gigz.pk\/php\/?lesson=break-and-continue","og_locale":"en_US","og_type":"article","og_title":"break and continue - Learn PHP with GiGz.PK","og_description":"Learn PHP break and continue statements with examples. Understand loop control, skipping iterations, and stopping loops easily.","og_url":"https:\/\/gigz.pk\/php\/?lesson=break-and-continue","og_site_name":"Learn PHP with GiGz.PK","article_modified_time":"2026-05-21T14:38:29+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/php\/?lesson=break-and-continue","url":"https:\/\/gigz.pk\/php\/?lesson=break-and-continue","name":"break and continue - Learn PHP with GiGz.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/php\/#website"},"datePublished":"2026-05-20T09:11:53+00:00","dateModified":"2026-05-21T14:38:29+00:00","description":"Learn PHP break and continue statements with examples. Understand loop control, skipping iterations, and stopping loops easily.","breadcrumb":{"@id":"https:\/\/gigz.pk\/php\/?lesson=break-and-continue#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/php\/?lesson=break-and-continue"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/php\/?lesson=break-and-continue#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/php"},{"@type":"ListItem","position":2,"name":"PHP Fundamentals (Beginner Level) > Loops > break and continue"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/php\/#website","url":"https:\/\/gigz.pk\/php\/","name":"Learn PHP with GiGz.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/php\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/lesson\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}