<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: PHP &#8211; Delete selected items from an array</title>
	<atom:link href="http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/</link>
	<description>The biggest and the best in the Northwest</description>
	<lastBuildDate>Sat, 03 Jul 2010 05:37:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: web development</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-3087</link>
		<dc:creator>web development</dc:creator>
		<pubDate>Wed, 23 Jun 2010 08:49:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-3087</guid>
		<description>very helpful post! thanks!</description>
		<content:encoded><![CDATA[<p>very helpful post! thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Althauser</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-2151</link>
		<dc:creator>Ben Althauser</dc:creator>
		<pubDate>Wed, 16 Sep 2009 17:10:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-2151</guid>
		<description>with an edit from the php array_dif example, here&#039;s a nice comparison and removal script,

 &quot;green&quot;, &quot;red&quot;, &quot;blue&quot;, &quot;red&quot;, &quot;purple&quot;);
$array2 = array(&quot;b&quot; =&gt; &quot;green&quot;, &quot;yellow&quot;, &quot;red&quot;);
$result = array_diff($array1, $array2);
$myray[] = implode(&quot;,&quot;,$result);
echo implode(&quot;,&quot;,$myray);
?&gt;</description>
		<content:encoded><![CDATA[<p>with an edit from the php array_dif example, here&#8217;s a nice comparison and removal script,</p>
<p> &#8220;green&#8221;, &#8220;red&#8221;, &#8220;blue&#8221;, &#8220;red&#8221;, &#8220;purple&#8221;);<br />
$array2 = array(&#8220;b&#8221; =&gt; &#8220;green&#8221;, &#8220;yellow&#8221;, &#8220;red&#8221;);<br />
$result = array_diff($array1, $array2);<br />
$myray[] = implode(&#8220;,&#8221;,$result);<br />
echo implode(&#8220;,&#8221;,$myray);<br />
?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-1891</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 28 Aug 2009 16:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-1891</guid>
		<description>I have used unset() on an array element to remove the element.

I like your solution!</description>
		<content:encoded><![CDATA[<p>I have used unset() on an array element to remove the element.</p>
<p>I like your solution!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cool</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-1855</link>
		<dc:creator>Cool</dc:creator>
		<pubDate>Thu, 30 Jul 2009 16:40:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-1855</guid>
		<description>That&#039;s very helpfu.
Thanks for the tips.</description>
		<content:encoded><![CDATA[<p>That&#8217;s very helpfu.<br />
Thanks for the tips.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Schumacher</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-1852</link>
		<dc:creator>Josh Schumacher</dc:creator>
		<pubDate>Mon, 27 Jul 2009 17:22:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-1852</guid>
		<description>@Cool, yes you can use a combo of array_filter with another helper to remove any elements with the letter &#039;c&#039; from you array above.  Here&#039;s some sample code for your use case:

$array = array(&#039;abc&#039;,&#039;cde&#039;,&#039;efg&#039;);

function hasNoC($val) {
     return (stripos($val, &#039;c&#039;) === false);
}

$clean_array = array_filter($array, &quot;hasNoC&quot;);</description>
		<content:encoded><![CDATA[<p>@Cool, yes you can use a combo of array_filter with another helper to remove any elements with the letter &#8216;c&#8217; from you array above.  Here&#8217;s some sample code for your use case:</p>
<p>$array = array(&#8216;abc&#8217;,'cde&#8217;,'efg&#8217;);</p>
<p>function hasNoC($val) {<br />
     return (stripos($val, &#8216;c&#8217;) === false);<br />
}</p>
<p>$clean_array = array_filter($array, &#8220;hasNoC&#8221;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cool</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-1851</link>
		<dc:creator>Cool</dc:creator>
		<pubDate>Mon, 27 Jul 2009 17:05:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-1851</guid>
		<description>For example,

$array = array(abc,cde, efg);

If i want to remove elements that match with character &#039;c&#039; from an array like above,

can it be works by using array_filter() and preg_match()?

Coz from wat i see here is using function within it to remove the elements. so i need to put whole command  in current function, right?

Please correct me if i&#039;m wrong.</description>
		<content:encoded><![CDATA[<p>For example,</p>
<p>$array = array(abc,cde, efg);</p>
<p>If i want to remove elements that match with character &#8216;c&#8217; from an array like above,</p>
<p>can it be works by using array_filter() and preg_match()?</p>
<p>Coz from wat i see here is using function within it to remove the elements. so i need to put whole command  in current function, right?</p>
<p>Please correct me if i&#8217;m wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kaveh Rassoulzadegan</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-1741</link>
		<dc:creator>Kaveh Rassoulzadegan</dc:creator>
		<pubDate>Mon, 20 Apr 2009 16:09:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-1741</guid>
		<description>You may change your discussion title. It is too global.

Maybe with something like :

&quot;Delete selected items from an array with conditions&quot;

for people looking for unset or array_splice.</description>
		<content:encoded><![CDATA[<p>You may change your discussion title. It is too global.</p>
<p>Maybe with something like :</p>
<p>&#8220;Delete selected items from an array with conditions&#8221;</p>
<p>for people looking for unset or array_splice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Schumacher</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-1724</link>
		<dc:creator>Josh Schumacher</dc:creator>
		<pubDate>Tue, 24 Mar 2009 03:12:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-1724</guid>
		<description>Artur - If you need to completely delete an element from an array, use unset().  So to delete the element 0 from $arr, use: unset($arr[0]);</description>
		<content:encoded><![CDATA[<p>Artur &#8211; If you need to completely delete an element from an array, use unset().  So to delete the element 0 from $arr, use: unset($arr[0]);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Artur</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-1721</link>
		<dc:creator>Artur</dc:creator>
		<pubDate>Mon, 23 Mar 2009 21:46:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-1721</guid>
		<description>David,

Well, yes, looks like it will take care of deleting the data in the array string but it does not get rid of the string, how can that be done? For example, I am looking to remove the $arr[0] alltogether

thanks</description>
		<content:encoded><![CDATA[<p>David,</p>
<p>Well, yes, looks like it will take care of deleting the data in the array string but it does not get rid of the string, how can that be done? For example, I am looking to remove the $arr[0] alltogether</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Barrett</title>
		<link>http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/comment-page-1/#comment-1709</link>
		<dc:creator>David Barrett</dc:creator>
		<pubDate>Tue, 10 Feb 2009 21:01:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.joshschumacher.com/2007/03/22/php-delete-selected-items-from-an-array/#comment-1709</guid>
		<description>Deleting a particular record from a string array is very straightforward:

$arr[$id]=&#039;&#039;;
$arr=array_filter(arr);
$arr=array_values($arr);

Where $id is the row you wish to delete.  array_filter with no callback deletes and FALSE values in the array, and an empty string is FALSE.  Using this theory it will work for other array types too - so long as you don&#039;t need any false values left in the array!</description>
		<content:encoded><![CDATA[<p>Deleting a particular record from a string array is very straightforward:</p>
<p>$arr[$id]=&#8221;;<br />
$arr=array_filter(arr);<br />
$arr=array_values($arr);</p>
<p>Where $id is the row you wish to delete.  array_filter with no callback deletes and FALSE values in the array, and an empty string is FALSE.  Using this theory it will work for other array types too &#8211; so long as you don&#8217;t need any false values left in the array!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
