<?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 Archives - The Code Developer</title>
	<atom:link href="https://www.thecodedeveloper.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.thecodedeveloper.com/category/php/</link>
	<description>The Code Developer is a Programming Blog.</description>
	<lastBuildDate>Sun, 02 Dec 2018 16:04:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>How to merge two or more arrays into one array in PHP ?</title>
		<link>https://www.thecodedeveloper.com/merge-two-or-more-arrays-into-one-array/</link>
					<comments>https://www.thecodedeveloper.com/merge-two-or-more-arrays-into-one-array/#respond</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Sun, 02 Dec 2018 15:16:35 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Array Function]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=3618</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="1020" height="620" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/12/merge-two-or-more-arrays-into-one-array.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="merge two or more arrays into one array" decoding="async" fetchpriority="high" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/12/merge-two-or-more-arrays-into-one-array.png 1020w, https://www.thecodedeveloper.com/wp-content/uploads/2018/12/merge-two-or-more-arrays-into-one-array-442x269.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/12/merge-two-or-more-arrays-into-one-array-768x467.png 768w" sizes="(max-width: 1020px) 100vw, 1020px" /></div>
<p>In this article you will learn how to merge two or more arrays into one array in PHP. You can easily do it after use array_merge() function to merge the elements or values of two or more arrays together into a single array. array_merge() function The array_merge() function merges one or more arrays into one [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/merge-two-or-more-arrays-into-one-array/">How to merge two or more arrays into one array in PHP ?</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="1020" height="620" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/12/merge-two-or-more-arrays-into-one-array.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="merge two or more arrays into one array" decoding="async" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/12/merge-two-or-more-arrays-into-one-array.png 1020w, https://www.thecodedeveloper.com/wp-content/uploads/2018/12/merge-two-or-more-arrays-into-one-array-442x269.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/12/merge-two-or-more-arrays-into-one-array-768x467.png 768w" sizes="(max-width: 1020px) 100vw, 1020px" /></div><p>In this article you will learn how to <strong>merge two or more arrays into one array</strong> in PHP. You can easily do it after use <strong>array_merge()</strong> function to merge the elements or values of two or more arrays together into a single array.</p>
<h4 class="sitemaincolor">array_merge() function</h4>
<p>The <strong>array_merge()</strong> function merges one or more arrays into one array. <b>Note:</b> If two or more array elements have the same key, the last one overrides the others.</p>
<h2>Merge two or more arrays into one array in PHP</h2>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$array1 = array(&quot;yellow&quot;, &quot;red&quot;, &quot;green&quot;, &quot;orange&quot;, &quot;purple&quot;);
$array2 = array(&quot;pink&quot;, &quot;brown&quot;, &quot;green&quot;, &quot;orange&quot;, &quot;red&quot;);
$array  = array_merge($array1, $array2);
print_r($array);
?&gt;
</pre>
<h5>The above example will output:</h5>
<pre class="brush: php; title: ; notranslate">
Array
(
    &#x5B;0] =&gt; yellow
    &#x5B;1] =&gt; red
    &#x5B;2] =&gt; green
    &#x5B;3] =&gt; orange
    &#x5B;4] =&gt; purple
    &#x5B;5] =&gt; pink
    &#x5B;6] =&gt; brown
    &#x5B;7] =&gt; green
    &#x5B;8] =&gt; orange
    &#x5B;9] =&gt; red
)
</pre>
<p>The post <a href="https://www.thecodedeveloper.com/merge-two-or-more-arrays-into-one-array/">How to merge two or more arrays into one array in PHP ?</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/merge-two-or-more-arrays-into-one-array/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to merge two arrays without duplicate values in PHP?</title>
		<link>https://www.thecodedeveloper.com/merge-two-arrays-without-duplicate-values-in-php/</link>
					<comments>https://www.thecodedeveloper.com/merge-two-arrays-without-duplicate-values-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Fri, 30 Nov 2018 17:22:50 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Array Function]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=3333</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="1020" height="620" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/11/merge-two-arrays-without-duplicate-values.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="How to merge two arrays without duplicate values in PHP?" decoding="async" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/11/merge-two-arrays-without-duplicate-values.png 1020w, https://www.thecodedeveloper.com/wp-content/uploads/2018/11/merge-two-arrays-without-duplicate-values-442x269.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/11/merge-two-arrays-without-duplicate-values-768x467.png 768w" sizes="(max-width: 1020px) 100vw, 1020px" /></div>
<p>In this tutorial, we will explain you how to merge two arrays without duplicate values in PHP. You can use the PHP array_unique() function and PHP array_merge() function together to merge two arrays into one array without duplicate values in PHP. Merge two arrays You can use PHP array_merge function for merging both arrays into [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/merge-two-arrays-without-duplicate-values-in-php/">How to merge two arrays without duplicate values in PHP?</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="1020" height="620" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/11/merge-two-arrays-without-duplicate-values.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="How to merge two arrays without duplicate values in PHP?" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/11/merge-two-arrays-without-duplicate-values.png 1020w, https://www.thecodedeveloper.com/wp-content/uploads/2018/11/merge-two-arrays-without-duplicate-values-442x269.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/11/merge-two-arrays-without-duplicate-values-768x467.png 768w" sizes="auto, (max-width: 1020px) 100vw, 1020px" /></div><p>In this tutorial, we will explain you <strong>how to merge two arrays without duplicate values in PHP</strong>. You can use the PHP <strong>array_unique()</strong> function and PHP <strong>array_merge()</strong> function together to merge two arrays into one array without duplicate values in PHP.</p>
<h2>Merge two arrays</h2>
<p>You can use PHP <strong>array_merge</strong> function for merging both arrays into one array. it&#8217;s giving output like this.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$array1 = array(&quot;yellow&quot;, &quot;red&quot;, &quot;green&quot;, &quot;orange&quot;, &quot;purple&quot;);
$array2 = array(&quot;pink&quot;, &quot;brown&quot;, &quot;green&quot;, &quot;orange&quot;, &quot;red&quot;);
$array  = array_merge($array1, $array2);
print_r($array);
?&gt;
</pre>
<pre class="brush: php; title: ; notranslate">
Array
(
    &#x5B;0] =&gt; yellow
    &#x5B;1] =&gt; red
    &#x5B;2] =&gt; green
    &#x5B;3] =&gt; orange
    &#x5B;4] =&gt; purple
    &#x5B;5] =&gt; pink
    &#x5B;6] =&gt; brown
    &#x5B;7] =&gt; green
    &#x5B;8] =&gt; orange
    &#x5B;9] =&gt; red
)
</pre>
<p>In above output you can see there are many duplicate entries But we want to remove these duplicate entries before merging both array.</p>
<h2>Merge two arrays without duplicate values in PHP</h2>
<p>Now we will use <a href="https://www.thecodedeveloper.com/function-array_unique/" rel="noopener" target="_blank">array_unique()</a> and <a href="https://www.thecodedeveloper.com/merge-two-or-more-arrays-into-one-array/" rel="noopener" target="_blank">array_merge()</a> both PHP function together to merge two arrays and remove duplicate values like in below example:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$array1 = array(&quot;yellow&quot;, &quot;red&quot;, &quot;green&quot;, &quot;orange&quot;, &quot;purple&quot;);
$array2 = array(&quot;pink&quot;, &quot;brown&quot;, &quot;green&quot;, &quot;orange&quot;, &quot;red&quot;);
$array = array_unique(array_merge($array1, $array2));
print_r($array);
?&gt;
</pre>
<h5>The above example will output:</h5>
<pre class="brush: php; title: ; notranslate">
Array
(
    &#x5B;0] =&gt; yellow
    &#x5B;1] =&gt; red
    &#x5B;2] =&gt; green
    &#x5B;3] =&gt; orange
    &#x5B;4] =&gt; purple
    &#x5B;5] =&gt; pink
    &#x5B;6] =&gt; brown
)
</pre>
<p>In above output you can see we merged both arrays without duplicate values that&#8217;s what we want.</p>
<p>The post <a href="https://www.thecodedeveloper.com/merge-two-arrays-without-duplicate-values-in-php/">How to merge two arrays without duplicate values in PHP?</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/merge-two-arrays-without-duplicate-values-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Remove Empty Array Elements and Reindex In PHP</title>
		<link>https://www.thecodedeveloper.com/remove-empty-array-elements-and-reindex/</link>
					<comments>https://www.thecodedeveloper.com/remove-empty-array-elements-and-reindex/#respond</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Sun, 21 Oct 2018 17:39:23 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Array Function]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=3540</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="1020" height="620" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/10/remove-empty-array-elements-and-reindex-in-php.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Remove Empty Array Elements and Reindex from an array in PHP" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/10/remove-empty-array-elements-and-reindex-in-php.png 1020w, https://www.thecodedeveloper.com/wp-content/uploads/2018/10/remove-empty-array-elements-and-reindex-in-php-442x269.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/10/remove-empty-array-elements-and-reindex-in-php-768x467.png 768w" sizes="auto, (max-width: 1020px) 100vw, 1020px" /></div>
<p>In this article you will learn how to remove empty array elements and reindex from an array in PHP. You can easily do it after use array_values() and array_filter() function together to remove empty array elements and reindex from an array in PHP. array_filter() function The PHP array_filter() function remove empty array elements or values [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/remove-empty-array-elements-and-reindex/">Remove Empty Array Elements and Reindex In PHP</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="1020" height="620" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/10/remove-empty-array-elements-and-reindex-in-php.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Remove Empty Array Elements and Reindex from an array in PHP" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/10/remove-empty-array-elements-and-reindex-in-php.png 1020w, https://www.thecodedeveloper.com/wp-content/uploads/2018/10/remove-empty-array-elements-and-reindex-in-php-442x269.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/10/remove-empty-array-elements-and-reindex-in-php-768x467.png 768w" sizes="auto, (max-width: 1020px) 100vw, 1020px" /></div><p>In this article you will learn how to <strong>remove empty array elements and reindex</strong> from an array in PHP. You can easily do it after use <strong>array_values()</strong> and <strong>array_filter()</strong> function together to <a href="https://www.thecodedeveloper.com/remove-empty-array-elements-in-php/">remove empty array elements</a> and reindex from an array in PHP.</p>
<h4 class="sitemaincolor">array_filter() function</h4>
<p>The PHP <strong>array_filter()</strong> function remove empty array elements or values from an array in PHP. This will also remove blank, null, false, 0 (zero) values.</p>
<h4 class="sitemaincolor">array_values() function</h4>
<p>The PHP <strong>array_values()</strong> function returns an array containing all the values of an array. The returned array will have numeric keys, starting at 0 and increase by 1.</p>
<h2>Remove Empty Array Elements and Reindex In PHP</h2>
<p>First let’s see the $stack array output :</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$stack = array(&quot;PHP&quot;, &quot;HTML&quot;, &quot;CSS&quot;, &quot;&quot;, &quot;JavaScript&quot;, null, 0);
print_r($stack);
?&gt;
</pre>
<p><strong>Output:</strong></p>
<pre class="brush: php; title: ; notranslate">
Array
(
    &#x5B;0] =&gt; PHP
    &#x5B;1] =&gt; HTML
    &#x5B;2] =&gt; CSS
    &#x5B;3] =&gt; 
    &#x5B;4] =&gt; JavaScript
    &#x5B;5] =&gt; 
    &#x5B;6] =&gt; 0
)
</pre>
<p>In above output we want to remove blank, null, 0 (zero) values and then reindex array elements. Now we will use array_values() and array_filter() function together like in below example:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$stack = array(&quot;PHP&quot;, &quot;HTML&quot;, &quot;CSS&quot;, &quot;&quot;, &quot;JavaScript&quot;, null, 0);
print_r(array_values(array_filter($stack)));
?&gt;
</pre>
<p><strong>Output:</strong></p>
<pre class="brush: php; title: ; notranslate">
Array
(
    &#x5B;0] =&gt; PHP
    &#x5B;1] =&gt; HTML
    &#x5B;2] =&gt; CSS
    &#x5B;3] =&gt; JavaScript
)
</pre>
<p>The post <a href="https://www.thecodedeveloper.com/remove-empty-array-elements-and-reindex/">Remove Empty Array Elements and Reindex In PHP</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/remove-empty-array-elements-and-reindex/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Calculate the number of days between two dates in PHP</title>
		<link>https://www.thecodedeveloper.com/calculate-the-number-of-days-between-two-dates-in-php/</link>
					<comments>https://www.thecodedeveloper.com/calculate-the-number-of-days-between-two-dates-in-php/#comments</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Sat, 29 Sep 2018 11:38:21 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=3391</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="1020" height="620" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/09/calculate-the-number-of-days-between-two-dates-in-php.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Calculate the number of days between two dates in PHP" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/09/calculate-the-number-of-days-between-two-dates-in-php.png 1020w, https://www.thecodedeveloper.com/wp-content/uploads/2018/09/calculate-the-number-of-days-between-two-dates-in-php-442x269.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/09/calculate-the-number-of-days-between-two-dates-in-php-768x467.png 768w" sizes="auto, (max-width: 1020px) 100vw, 1020px" /></div>
<p>In this article we will explain how to calculate the number of days between two dates in PHP. There are many different way to find the number of days between two dates in PHP. Calculate the number of days between two dates in PHP Method 1# First we will convert start date and end date [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/calculate-the-number-of-days-between-two-dates-in-php/">Calculate the number of days between two dates in PHP</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="1020" height="620" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/09/calculate-the-number-of-days-between-two-dates-in-php.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Calculate the number of days between two dates in PHP" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/09/calculate-the-number-of-days-between-two-dates-in-php.png 1020w, https://www.thecodedeveloper.com/wp-content/uploads/2018/09/calculate-the-number-of-days-between-two-dates-in-php-442x269.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/09/calculate-the-number-of-days-between-two-dates-in-php-768x467.png 768w" sizes="auto, (max-width: 1020px) 100vw, 1020px" /></div><p>In this article we will explain how to <strong>calculate the number of days between two dates</strong> in PHP. There are many different way to <strong>find the number of days between two dates</strong> in PHP.</p>
<h2>Calculate the number of days between two dates in PHP</h2>
<h3 class="sitemaincolor" >Method 1#</h3>
<p>First we will convert start date and end date into to unix timestamps using <strong>strtotime(</strong>) function, then substract end date to start date then it will give you the difference in seconds, which you divide by 86400 (total seconds in a day) to give you an approximate total of days in that range.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
function dateDifference($start_date, $end_date)
{
    // calulating the difference in timestamps 
    $diff = strtotime($start_date) - strtotime($end_date);
     
    // 1 day = 24 hours 
    // 24 * 60 * 60 = 86400 seconds
    return ceil(abs($diff / 86400));
}
 
// start date 
$start_date = &quot;2016-01-02&quot;;
 
// end date 
$end_date = &quot;2016-01-21&quot;;
 
// call dateDifference() function to find the number of days between two dates
$dateDiff = dateDifference($start_date, $end_date);
 
echo &quot;Difference between two dates: &quot; . $dateDiff . &quot; Days &quot;;
?&gt; 
</pre>
<h4>The above example will output:</h4>
<pre class="brush: php; title: ; notranslate">
Difference between two dates: 19 Days
</pre>
<h4>Three PHP functions are used in the above script to find the number of days between two dates.</h4>
<p>The <strong>strtotime()</strong> function is a built-in function in PHP which is used to convert an English textual date-time description to a UNIX timestamp.<br />
The <strong>abs()</strong> function returns the absolute (positive) value of a number.<br />
The <strong>ceil()</strong> function is used to round a number to the nearest greater integer.</p>
<h3 class="sitemaincolor">Method 2# DateTime::diff()</h3>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$start_date = date_create(&quot;2016-01-02&quot;);
$end_date   = date_create(&quot;2016-01-21&quot;);

//difference between two dates
$diff = date_diff($start_date,$end_date);

//find the number of days between two dates
echo &quot;Difference between two dates: &quot;.$diff-&gt;format(&quot;%a&quot;). &quot; Days &quot;;
?&gt;
</pre>
<h4>The above example will output:</h4>
<pre class="brush: php; title: ; notranslate">
Difference between two dates: 19 Days
</pre>
<h3 class="sitemaincolor">Method 3#  DateTime::diff()</h3>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$start_date = new DateTime('2016-01-02');
$end_date = new DateTime('2016-01-21');

//difference between two dates
$diff = $start_date-&gt;diff($end_date);

//find the number of days between two dates
echo &quot;Difference between two dates: &quot;.$diff-&gt;format(&quot;%a&quot;). &quot; Days &quot;;
?&gt;
</pre>
<h4>The above example will output:</h4>
<pre class="brush: php; title: ; notranslate">
Difference between two dates: 19 Days
</pre>
<p>In the above Method 2#, Method 3# used <strong>date_diff()</strong> function returns the difference between two DateTime objects.</p>
<p><strong><em>I hope you like this Post, Please send me any comment, suggestion or correction you may have &#8211; we are here to solve your problems. Thanks</em></strong></p>
<p>The post <a href="https://www.thecodedeveloper.com/calculate-the-number-of-days-between-two-dates-in-php/">Calculate the number of days between two dates in PHP</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/calculate-the-number-of-days-between-two-dates-in-php/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
