{"id":9728,"date":"2020-01-30T09:04:02","date_gmt":"2020-01-30T09:04:02","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=9728"},"modified":"2022-05-08T12:07:22","modified_gmt":"2022-05-08T12:07:22","slug":"loop-with-numeric-and-associative-array","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/loop-with-numeric-and-associative-array\/","title":{"rendered":"What is the difference between numeric and associative array in loop with example?"},"content":{"rendered":"\n<p><strong>For Loop with Numeric Array:-<\/strong><br> Numeric Array uses in For Loop for Declaration and Initialization as numeric index values are store and access.<br> ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/90a74ff46cb0618f75e21dfbc9d67fad.js\"><\/script>\n\n\n\n<p><strong>For Loop with Associative Array:-<\/strong><br> The associative array used in For Loop with strings as an index. Associative array stores element values associated with key or index ([]= this is index or key) values.<br> ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/2edfccc32867d092ff530bb8e2bc3e50.js\"><\/script>\n\n\n\n<p><strong>Foreach Loop with Numeric array:-<\/strong><br>Foreach Loop works only on arrays. It is used as each index, key or value pair in an array.<br> ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/d03656e9351a67aebea66c67c189a364.js\"><\/script>\n\n\n\n<p><strong>Foreach Loop with Associative array:- <\/strong><br> ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/0884d22bf3b15b22876e787502dbc5cf.js\"><\/script>\n\n\n\n<p><strong>While Loop with Numeric Array:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/3f72f2a7d950c1103354b79b8ce4c6b3.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>For Loop with Numeric Array:- Numeric Array uses in For Loop for Declaration and Initialization as numeric index values are store and access. ex:- For Loop with Associative Array:- The associative array used in For Loop with strings as an index. Associative array stores element values associated with key or index ([]= this is index&#8230;<\/p>\n","protected":false},"author":1,"featured_media":9761,"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":[490,5837,519,5836,377],"class_list":["post-9728","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-array","tag-associative","tag-example","tag-loop","tag-numeric"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9728","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=9728"}],"version-history":[{"count":6,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9728\/revisions"}],"predecessor-version":[{"id":10066,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9728\/revisions\/10066"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/9761"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=9728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=9728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=9728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}