{"id":15642,"date":"2020-07-02T16:40:41","date_gmt":"2020-07-02T16:40:41","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=15642"},"modified":"2022-04-13T15:58:38","modified_gmt":"2022-04-13T15:58:38","slug":"php-7-essential-guide-php-adding-to-an-array","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/php-7-essential-guide-php-adding-to-an-array\/","title":{"rendered":"PHP 7 Essential Guide- PHP adding to an array-"},"content":{"rendered":"\n<p>In this blog I am going to explain that how to adding array in PHP. So, as stated in the PHP documentation, if you&#8217;r only pushing a single element every time (like in a loop ) or a single element once, it&#8217;s best to use the #value[] = 15; method not only because it&#8217;s less character to the same operation, but it also performance over a function call, which array_push(). <\/p>\n\n\n\n<p>It means if you are using in a array single item at a time. If all values are known at the same time, it&#8217;s possible best just to use the array_push it depends on how many items must be added the extra character from array name each time may be more of a performance than the function call overhead.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/068d6d96d3f2ba46878116f2257ab814.js\"><\/script>\n\n\n\n<p><strong>Output-<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"145\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/adding-array.png\" alt=\"\" class=\"wp-image-15647\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/adding-array.png 843w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/adding-array-300x52.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/adding-array-768x132.png 768w\" sizes=\"auto, (max-width: 843px) 100vw, 843px\" \/><\/figure>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_76057\"><iframe loading=\"lazy\"  id=\"_ytid_83992\"  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_76057\"  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 class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>In this blog I am going to explain that how to adding array in PHP. So, as stated in the PHP documentation, if you&#8217;r only pushing a single element every&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5150],"tags":[490,6229,1122,177,6228],"class_list":["post-15642","post","type-post","status-publish","format-standard","hentry","category-php","tag-array","tag-essential","tag-guide","tag-php","tag-php7"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/15642","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=15642"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/15642\/revisions"}],"predecessor-version":[{"id":24699,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/15642\/revisions\/24699"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=15642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=15642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=15642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}