{"id":9668,"date":"2020-01-28T09:30:21","date_gmt":"2020-01-28T09:30:21","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=9668"},"modified":"2022-05-08T12:07:22","modified_gmt":"2022-05-08T12:07:22","slug":"php-loop-with-example","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/php-loop-with-example\/","title":{"rendered":"How many types of loops are there in PHP?"},"content":{"rendered":"\n<p><strong>While Loop:-<\/strong><br>While loop keeps repeating an action until a condition returns false.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/0f316ced63ff5ae937eb9c53359ec0fe.js\"><\/script>\n\n\n\n<p><strong>Nested While loop:-<br><\/strong>Nested while loops work as while loop but in this case, you use one or more while loop condition in one while loop.<br><strong> ex:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/cd2f0b03c5e8cd60b9b84ee24c64de4b.js\"><\/script>\n\n\n\n<p><strong>Do While loop:-<\/strong><br>Do While loop work as while loop but in this case Before executed then check condition is true then execute next if condition is false then exit.<br> <strong>ex:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/bfcc5a08dcfc5376d8c13ceffb5154eb.js\"><\/script>\n\n\n\n<p><strong>Nested Do While loop:-<\/strong><br>Nested Do While loop work as  Do While loop but in this case you can add or use one or more do while loop in one parent do while loop.<br><strong> ex:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/38cbd627e2038aeaf3f83394f51cb683.js\"><\/script>\n\n\n\n<p><strong>For loop :-<\/strong><br>For loop is frequently used where you will be a fixed number of times.<br> <strong>ex:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/555f95c8b9b92676fe82a514d12e5073.js\"><\/script>\n\n\n\n<p><strong>Nested for loop :-<\/strong><br> Nested for loop work like as for loop but one or more for loop in one parent for loop.<br> <strong>ex:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/fdb23995f451cea62757d0f66b127b26.js\"><\/script>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_33522\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_81850\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_33522\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>While Loop:-While loop keeps repeating an action until a condition returns false. Nested While loop:-Nested while loops work as while loop but in this case, you use one or more while loop condition in one while loop. ex:- Do While loop:-Do While loop work as while loop but in this case Before executed then check&#8230;<\/p>\n","protected":false},"author":1,"featured_media":9670,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5150],"tags":[6220,6218,5836,177,6216],"class_list":["post-9668","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-do-while-loop","tag-for-loop","tag-loop","tag-php","tag-while-loop"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=9668"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9668\/revisions"}],"predecessor-version":[{"id":24989,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9668\/revisions\/24989"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/9670"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=9668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=9668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=9668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}