{"id":2181,"date":"2013-02-06T13:29:57","date_gmt":"2013-02-06T13:29:57","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=2181"},"modified":"2013-02-06T13:29:57","modified_gmt":"2013-02-06T13:29:57","slug":"php-remove-first-array-element-how-to-remove-first-array-item","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/php-remove-first-array-element-how-to-remove-first-array-item\/","title":{"rendered":"Using PHP To Remove First Array Element \/ Item"},"content":{"rendered":"<p>Arrays are an important concept in PHP. So while it&#8217;s easy to create &amp; destroy a complete array, it can be immensely useful to find out how to remove first array item using PHP. In this article, I am going to share very easy way to use <em><strong>PHP to\u00a0<\/strong><strong>remove first array element\u00a0<\/strong><\/em>by making use of easy to follow examples. So read on to find out more.<!--more--><\/p>\n<h2>How to use PHP to Remove First Array Element \/ Item<\/h2>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=2181\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p>Let&#8217;s assume that we an array in PHP, that contains the fruit names. So in this example, we will see how to remove the first item from this fruits array.<\/p>\n<h3>Example: Remove first element from an array using PHP<\/h3>\n<pre class=\"lang:xhtml decode:true\" title=\"Example\">&lt;?php \n\/\/Declare an empty array\n$my_fruits_array = array('apple', 'mango', 'grapes', 'pineapple');\n\n\/\/Print the contents of the array. Use the &lt;pre&gt; tags to output the array in readable format.\necho 'Following are the original array contents:&lt;br \/&gt;';\necho '&lt;pre&gt;';\nprint_r($my_fruits_array);\necho '&lt;\/pre&gt;';\n\n\/\/Remove First Element From Array Using PHP\narray_shift($my_fruits_array);\n\n\/\/Print the contents of the array. Use the &lt;pre&gt; tags to output the array in readable format.\necho 'Following are the array contents AFTER removing the first item from array:&lt;br \/&gt;';\necho '&lt;pre&gt;';\nprint_r($my_fruits_array);\necho '&lt;\/pre&gt;';\n?&gt;<\/pre>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=2181\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p><strong>Simple, isn&#8217;t it?<\/strong><\/p>\n<p>Do you know of any other ways to use <strong><em>PHP to\u00a0remove first array element<\/em><\/strong>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Arrays are an important concept in PHP. So while it&#8217;s easy to create &amp; destroy a complete array, it can be immensely useful to find out how to remove first array item using PHP. In this article, I am going to share very easy way to use PHP to\u00a0remove first array element\u00a0by making use of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":141,"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":""},"categories":[10,13],"tags":[33],"class_list":["post-2181","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-tips-and-tricks","category-tips-and-tricks","tag-php-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-zb","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/2181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=2181"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/2181\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=2181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=2181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=2181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}