{"id":67,"date":"2008-01-13T20:04:24","date_gmt":"2008-01-13T15:04:24","guid":{"rendered":"http:\/\/codeinmybug.wordpress.com\/2008\/01\/13\/proposal-for-a-new-array-syntax-in-php\/"},"modified":"2008-05-09T11:44:57","modified_gmt":"2008-05-09T06:14:57","slug":"proposal-for-a-new-array-syntax-in-php","status":"publish","type":"post","link":"https:\/\/projectbee.org\/blog\/archive\/proposal-for-a-new-array-syntax-in-php\/","title":{"rendered":"Proposal for a new Array Syntax in PHP"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright\" style=\"float: right;\" src=\"http:\/\/projectbee.org\/blog\/wp-content\/uploads\/2008\/01\/php.gif\" alt=\"PHP Logo\" width=\"129\" height=\"72\" align=\"right\" \/>A new array syntax has been proposed (for quite some time) for defining arrays in PHP. Currently, we use <a href=\"http:\/\/in2.php.net\/manual\/en\/function.array.php\">array()<\/a> construct to create an array. Some examples could be:<\/p>\n<blockquote><p><em>$myArray = array(1, 2, 3, 4, 5);<br \/>\n$yourArray = array(1 =&gt; &#8220;one&#8221;, 2 =&gt; &#8220;two&#8221;, &#8220;three&#8221;);<br \/>\n$herArray = array(1, 2, 3, array(4 =&gt; &#8220;four&#8221;, &#8220;five&#8221;));<\/em><\/p><\/blockquote>\n<p>The proposal is to use square brackets ( <strong>[ ] <\/strong>) to define an array. If passed, we would be able rewrite the above examples as:<\/p>\n<blockquote><p><em><br \/>\n$myArray = [1, 2, 3, 4, 5];<br \/>\n$yourArray = [1 =&gt; &#8220;one&#8221;, 2 =&gt; &#8220;two&#8221;, &#8220;three&#8221;);<br \/>\n$herArray = [1, 2, 3, [4 =&gt; &#8220;four&#8221;, &#8220;five&#8221;]];<\/em><\/p><\/blockquote>\n<p>There&#8217;s a good deal of discussion going on in the internal mailing list with almost equal number of people voting &#8220;for&#8221; and &#8220;against&#8221; it. <a href=\"http:\/\/aspn.activestate.com\/ASPN\/Mail\/Message\/php-Dev\/3598121\">Rasmus, isn&#8217;t not very supportive, yet has voted for the new proposal<\/a>.<\/p>\n<p>To be pretty honest, I am still not very sure if it&#8217;s going to be worth the trade-offs.<br \/>\nAnyhoo! Let&#8217;s wait and watch. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A new array syntax has been proposed (for quite some time) for defining arrays in PHP. Currently, we use array() construct to create an array. Some examples could be: $myArray = array(1, 2, 3, 4, 5); $yourArray = array(1 =&gt; &#8220;one&#8221;, 2 =&gt; &#8220;two&#8221;, &#8220;three&#8221;); $herArray = array(1, 2, 3, array(4 =&gt; &#8220;four&#8221;, &#8220;five&#8221;)); The &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/projectbee.org\/blog\/archive\/proposal-for-a-new-array-syntax-in-php\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Proposal for a new Array Syntax in PHP&#8221;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[38,43,140],"tags":[217,220,141],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-news","category-php","category-programming","tag-code","tag-education","tag-rasmus"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pf2XR-15","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":0,"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"wp:attachment":[{"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/projectbee.org\/blog\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}