<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>php-demos &#8211; Extreme Web Designs</title>
	<atom:link href="https://theextremewebdesigns.com/blog/tag/php-demos-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://theextremewebdesigns.com/blog</link>
	<description>Web Design and Web Development</description>
	<lastBuildDate>Sun, 16 Jun 2013 19:05:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.5</generator>
<site xmlns="com-wordpress:feed-additions:1">156673191</site>	<item>
		<title>PHP Refresh Page Examples</title>
		<link>https://theextremewebdesigns.com/blog/php-refresh-page-examples/</link>
					<comments>https://theextremewebdesigns.com/blog/php-refresh-page-examples/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 16 Jun 2013 19:05:28 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[php-demos]]></category>
		<category><![CDATA[php-tips]]></category>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=3899</guid>

					<description><![CDATA[You may know how to refresh page using JavaScript. But, do you know how to refresh page using PHP? In this article, I am going to share very easy way to make page refresh using PHP. So read on for more info. How To Refresh Page Using PHP Let&#8217;s see how to do this by [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>You may know how to refresh page using JavaScript. But, do you know how to refresh page using PHP? In this article, I am going to share very easy way to <em><strong>make page refresh using PHP</strong></em>. So read on for more info.</p>
<p><span id="more-3899"></span></p>
<h2>How To Refresh Page Using PHP</h2>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=3899" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<p>Let&#8217;s see how to do this by means of an example. The following piece of code will refresh the page after 5 seconds. You may change it as per your needs.</p>
<h3>Example:</h3>
<pre class="lang:xhtml decode:true">echo 'This page will be refreshed after 5 seconds.';
echo '&lt;meta http-equiv="refresh" content="5"&gt;';</pre>
<p>To use the above code, simply copy the second line and change the seconds value from 5 to any value you desire.</p>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=3899" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<h5>Your Turn!</h5>
<p>Do you know of any other ways to <em><strong>refresh a page using PHP</strong></em>? Feel free to suggest by commenting below.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theextremewebdesigns.com/blog/php-refresh-page-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3899</post-id>	</item>
		<item>
		<title>PHP Return String From String Using Word Limit Examples</title>
		<link>https://theextremewebdesigns.com/blog/php-return-string-from-string-using-word-limit-examples/</link>
					<comments>https://theextremewebdesigns.com/blog/php-return-string-from-string-using-word-limit-examples/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 15 Jun 2013 19:05:42 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[php-demos]]></category>
		<category><![CDATA[php-tips]]></category>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=3892</guid>

					<description><![CDATA[Some times, it might be useful to extract string from a given string, based upon the word count. A good example of this is an excerpt of WordPress. As you know, an &#8220;excerpt&#8221; is just a sneak peak of the article. And it is limited by it&#8217;s word count (or any other desired criteria). So [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Some times, it might be useful to extract string from a given string, based upon the word count. A good example of this is an excerpt of WordPress. As you know, an &#8220;excerpt&#8221; is just a sneak peak of the article. And it is limited by it&#8217;s word count (or any other desired criteria). So how can we achieve the same result in PHP? In this article, I am going to share easy ways to <em><strong>return text from a given text, based upon the word count limit</strong></em>. So follow along for more info.</p>
<p><span id="more-3892"></span></p>
<h2>How To Limit String Using Word Count</h2>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=3892" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<p>Let&#8217;s see how to do this with an example.</p>
<h3>Example: Consider the following string on which we apply word limit using PHP</h3>
<pre class="lang:xhtml decode:true">This is a custom string. We are now going to apply PHP functions on this and return only the portion of the string based upon the word count.</pre>
<p>Now let&#8217;s limit the above string to a word count of 10 and then return the result. Use the following code to do so:</p>
<pre class="lang:xhtml decode:true">&lt;?php 
function word_limiter($string, $limit) 
{ 
	//break string based upon space
	$str_array = explode(" ", $string); 

	//return the extracted string with our word limit in place
	return implode(" ", array_splice($str_array, 0, $limit)); 
}

$string = 'This is a custom string. We are now going to apply PHP functions on this and return only the portion of the string based upon the word count.';

$word_limit = 10; //Change this based upon your needs

echo word_limiter($string, $word_limit);
?&gt;</pre>
<h3> Output:</h3>
<pre class="lang:xhtml decode:true">This is a custom string. We are now going to</pre>
<p>If you count the number of word in the above Output, you will notice that there are only 10 words. This is exactly what we wanted.</p>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=3892" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<h5>That&#8217;s it!</h5>
<p>Do you know of any other ways to <em><strong>limit string using word count in PHP</strong></em>? Feel free to suggest by commenting below.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theextremewebdesigns.com/blog/php-return-string-from-string-using-word-limit-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3892</post-id>	</item>
		<item>
		<title>How To Delete File Or Remove File Using PHP Examples</title>
		<link>https://theextremewebdesigns.com/blog/php-delete-file-or-remove-file/</link>
					<comments>https://theextremewebdesigns.com/blog/php-delete-file-or-remove-file/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 08 Feb 2013 06:57:42 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[php-demos]]></category>
		<category><![CDATA[php-tips]]></category>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=2240</guid>

					<description><![CDATA[When working with files in PHP, there may be a necessity to create files dynamically and at the same time, remove file or delete file using PHP.  In this article, I am going to share a very easy way to delete a file using PHP. The actual code is just 1 line, so it&#8217;s super easy to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>When working with files in PHP, there may be a necessity to create files dynamically and at the same time, <em><strong>remove file or delete file using PHP</strong></em>.  In this article, I am going to share a very easy way to delete a file using PHP. The actual code is just 1 line, so it&#8217;s super easy to follow.<span id="more-2240"></span></p>
<h2>Examples On How To Remove File Or Delete File Using PHP</h2>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=2240" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<p>To do this, we simply use the &#8220;unlink&#8221; function. So what unlink simply does is it <strong>&#8220;Deletes a file&#8221;</strong>. That&#8217;s it! Nothing more!</p>
<p><strong>Command:</strong></p>
<pre class="lang:php decode:true" title="Example">unlink( $filename );</pre>
<h3>Example: Using PHP to delete a file with the help of unlink function</h3>
<p>In this example, I am going to first create a sample test file and then once it is created in the following steps, I will delete the file using PHP.</p>
<pre class="lang:php decode:true" title="Example">&lt;?php
$temp_file_name = tempnam ('tmp/', "Test"); 

if( $temp_file_name )
{
	echo 'File successfully CREATED.&lt;br /&gt;';	
}
else
{
	echo 'Unable to CREATE file.&lt;br /&gt;';		
}

$fp = fopen($temp_file_name, "w"); 
fwrite($fp, 'Some sample content'); 
fclose($fp); 				

$delete_result = unlink($temp_file_name); 

if( $delete_result )
{
	echo 'File successfully DELETED.&lt;br /&gt;';	
}
else
{
	echo 'Unable to DELETE the file.&lt;br /&gt;';		
}
?&gt;</pre>
<p>If you have tried the demo, you will notice that first, the file is created &amp; in the succeeding step, the file is deleted. If you have not yet tried the demo, then do it by clicking the button below.</p>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=2240" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<p><strong>Your Turn!</strong><br />
Do you know of any other ways of using <em><strong>PHP to delete file or remove a file</strong></em>? Feel free to suggest by commenting below.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theextremewebdesigns.com/blog/php-delete-file-or-remove-file/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2240</post-id>	</item>
		<item>
		<title>How To Remove Duplicates From Array Using PHP</title>
		<link>https://theextremewebdesigns.com/blog/php-remove-duplicates-from-array-remove-duplicate-values-from-array-examples/</link>
					<comments>https://theextremewebdesigns.com/blog/php-remove-duplicates-from-array-remove-duplicate-values-from-array-examples/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 07 Feb 2013 06:12:22 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[php-demos]]></category>
		<category><![CDATA[php-tips]]></category>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=2221</guid>

					<description><![CDATA[While working with arrays, there may have been a time when you came across duplicate values in array. In some cases, these duplicates values are undesirable and you may want to remove these duplicate values from the same array. So do you know how to remove duplicate values from array? If not then here are [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>While <a title="PHP Add To An Array | Add Element To Array Using PHP Examples" href="https://theextremewebdesigns.com/blog/php-add-to-an-array-add-element-to-array-using-php-examples/" target="_blank">working with arrays</a>, there may have been a time when you came across duplicate values in array. In some cases, these duplicates values are undesirable and you may want to remove these duplicate values from the same array. So do you know how to remove duplicate values from array? If not then here are easy examples that show you how to  use <em><strong>PHP to remove duplicates from array</strong></em>. <span id="more-2221"></span></p>
<h2>Using PHP to Remove Duplicate Values From Array</h2>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=2221" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<p>Let&#8217;s consider that we have an array that contains fruits names. One of the fruits is now duplicated in the array and we would like to remove this duplicated value. Consider the following array below:</p>
<pre class="lang:php decode:true" title="Sample array with duplicate values">$my_fruits_array = array('apple', 'mango', 'grapes', 'pineapple', 'apple', 'guava', 'apple');</pre>
<p>As you can see in the above array, the fruit &#8220;apple&#8221; appears thrice i.e. it is duplicated twice. So now  we would like to retain only the first occurrence of &#8220;apple&#8221; and remove the other two duplicate values from the array.</p>
<h3>Example 1 &#8211; Remove duplicates from array using PHP</h3>
<pre class="lang:php decode:true" title="Example 1">&lt;?php 

echo 'Example 1: Removing a value from the array - Remove value "apple" &lt;br /&gt;';

//Declare an array
$my_fruits_array = array('apple', 'mango', 'grapes', 'pineapple', 'apple', 'guava', 'apple');

//Print the contents of the array.
echo 'Following are the original array contents:&lt;br /&gt;';
echo '&lt;pre&gt;';
print_r($my_fruits_array);
echo '&lt;/pre&gt;';

//Remove duplicated "apple" value from array
$my_fruits_array_new = array_unique($my_fruits_array);

//Print the contents of the array.
echo 'Following are the array contents AFTER removing the duplicate values from array:&lt;br /&gt;';
echo '&lt;pre&gt;';
print_r($my_fruits_array_new);
echo '&lt;/pre&gt;';
?&gt;</pre>
<h3>Example 2 &#8211; Delete Duplicates From Array Using PHP</h3>
<pre class="lang:php decode:true" title="Example 2">&lt;?php

echo '&lt;br /&gt;Example 2: Removing a value from the array - Remove value "grapes" &lt;br /&gt;';

$my_fruits_array = array('apple', 'mango', 'grapes', 'pineapple', 'apple', 'guava', 'apple');

//Print the contents of the array.
echo 'Following are the original array contents:&lt;br /&gt;';
echo '&lt;pre&gt;';
print_r($my_fruits_array);
echo '&lt;/pre&gt;';

//Remove "apple" value from array
$my_fruits_array_new = array_map('unserialize', array_unique(array_map('serialize', $my_fruits_array)));

//Print the contents of the array. 
echo 'Following are the array contents AFTER removing the value from array:&lt;br /&gt;';
echo '&lt;pre&gt;';
print_r($my_fruits_array_new);
echo '&lt;/pre&gt;';

?&gt;</pre>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=2221" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<h4>That&#8217;s it!</h4>
<p>Do you know of any other ways to use <em><strong>PHP to </strong><strong>delete duplicate values from array? </strong></em>Feel free to share by commenting below.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theextremewebdesigns.com/blog/php-remove-duplicates-from-array-remove-duplicate-values-from-array-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2221</post-id>	</item>
		<item>
		<title>How To Remove Whitespaces Using PHP &#8211; Examples</title>
		<link>https://theextremewebdesigns.com/blog/php-remove-whitespace-from-string-how-to-remove-whitespaces-examples/</link>
					<comments>https://theextremewebdesigns.com/blog/php-remove-whitespace-from-string-how-to-remove-whitespaces-examples/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 07 Feb 2013 05:13:20 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[php-demos]]></category>
		<category><![CDATA[php-tips]]></category>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=2207</guid>

					<description><![CDATA[If you have read my previous article on how to remove spaces from string, then you would be interested in this article too. In general terms, space is nothing but a gap between two words whereas a &#8220;whitespace&#8221; could be a tab, a space,  a line feed or a carriage return. The procedure to remove [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>If you have read my previous article on <a title="PHP Remove Space From String | How To Remove Spaces From String Examples" href="https://theextremewebdesigns.com/blog/php-remove-space-from-string-how-to-remove-spaces-from-string-examples/" target="_blank">how to remove spaces from string</a>, then you would be interested in this article too. In general terms, space is nothing but a gap between two words whereas a &#8220;<strong>whitespace</strong>&#8221; could be a tab, a space,  a line feed or a carriage return. The procedure to remove whitespaces from string is a bit different from the procedure to remove spaces from string. In this article, I am going to share a very easy way to use <em><strong>PHP to remove whitespaces from strings</strong></em> by means of examples.</p>
<p><span id="more-2207"></span></p>
<h2>Examples On Using PHP To Remove Whitespace From String</h2>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=2207" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<p>In order to see <strong>&#8220;<em>how to remove white spaces from string using PHP</em>&#8220;</strong>, let&#8217;s assume that we have some sample string and it contains spaces, tabs, carriage returns, etc. We will now remove these white spaces from this string.</p>
<h3>Example: Using PHP to remove white spaces from string</h3>
<pre class="lang:php decode:true" title="Example">&lt;?php

$content = "Hello, How are you doing today?		Ok ---    I am going 		...GREAT!!! 

How about yourself?
";

echo 'Original Content:'; echo '&lt;br /&gt;';
echo '&lt;pre&gt;'.$content.'&lt;/pre&gt;';
echo '&lt;br /&gt;';

//Remove all whitespaces from string using the function below
$new_content = preg_replace('/\s+/', '', $content);

echo 'New Content:'; echo '&lt;br /&gt;';
echo '&lt;pre&gt;'.$new_content.'&lt;/pre&gt;';
echo '&lt;br /&gt;';

?&gt;</pre>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=2207" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<h5>That&#8217;s it!</h5>
<p>Do you know of any other ways to <strong>remove whitespace from string using PHP</strong>? Feel free to suggest by commenting below.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theextremewebdesigns.com/blog/php-remove-whitespace-from-string-how-to-remove-whitespaces-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2207</post-id>	</item>
		<item>
		<title>Using PHP To Remove Last Array Element / Item</title>
		<link>https://theextremewebdesigns.com/blog/php-remove-last-array-element-how-to-remove-last-array-item-in-php/</link>
					<comments>https://theextremewebdesigns.com/blog/php-remove-last-array-element-how-to-remove-last-array-item-in-php/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 06 Feb 2013 13:46:30 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[php-demos]]></category>
		<category><![CDATA[php-tips]]></category>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=2186</guid>

					<description><![CDATA[Once again, we come back to Arrays. In the previous article, we have seen how important it could be remove first array item. Now it would be really helpful  to find out how to remove last array item using PHP. In this article, I am going to share very easy way to use PHP to remove [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Once again, we come back to Arrays. In the previous article, we have seen how important it could be remove first array item. Now it would be really helpful  to find out how to remove last array item using PHP. In this article, I am going to share very easy way to use <em><strong>PHP to remove last array element</strong></em> by making use of easy to follow examples. So read on to find out more.<span id="more-2186"></span></p>
<h2>How to use PHP to Remove Last Array Element / Item</h2>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=2186" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<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 last item from this fruits array.</p>
<h3>Example: Remove last element from an array using PHP</h3>
<pre class="lang:xhtml decode:true" title="Example">&lt;?php 
//Declare an empty array
$my_fruits_array = array('apple', 'mango', 'grapes', 'pineapple');

//Print the contents of the array. Use the &lt;pre&gt; tags to output the array in readable format.
echo 'Following are the original array contents:&lt;br /&gt;';
echo '&lt;pre&gt;';
print_r($my_fruits_array);
echo '&lt;/pre&gt;';

//Remove Last Element From Array Using PHP
array_pop($my_fruits_array);

//Print the contents of the array. Use the &lt;pre&gt; tags to output the array in readable format.
echo 'Following are the array contents AFTER removing the last item from array:&lt;br /&gt;';
echo '&lt;pre&gt;';
print_r($my_fruits_array);
echo '&lt;/pre&gt;';
?&gt;</pre>
<div class="make_demo">

	<form action="https://theextremewebdesigns.com/blog/wp-content/themes/ewd_blog_2017/try_demo.php?post_id=2186" method="post" name="form1" target="_blank" id="form1">


	<input type="hidden" name="shortcode_content" id="shortcode_content" value="" />

        <div class="try_demo_btn_container">


            <button type="submit" name="sbt_make_demo" id="sbt_make_demo" class="btn-primary btn-try-demo">
                Try Demo
            </button>


        </div><!-- .try_demo_btn_container -->

    </form>
    </div>
    
<p><strong>Simple, isn&#8217;t it?</strong></p>
<p>Do you know of any other ways to use <strong><em>PHP to remove last array element</em></strong>? Feel free to suggest by commenting below.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theextremewebdesigns.com/blog/php-remove-last-array-element-how-to-remove-last-array-item-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2186</post-id>	</item>
	</channel>
</rss>
