<?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/"
	xmlns:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: Five Cool PHP Array Functions</title>
	<atom:link href="http://www.brandonsavage.net/five-cool-php-array-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/five-cool-php-array-functions/</link>
	<description>The personal blog of Brandon Savage. Contains entries of a personal and professional nature focusing on PHP, Apple, LAMP, MySQL and Washington, DC.</description>
	<lastBuildDate>Mon, 15 Mar 2010 16:52:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Darren</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-2112</link>
		<dc:creator>Darren</dc:creator>
		<pubDate>Tue, 17 Nov 2009 04:54:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-2112</guid>
		<description>@Will K, what would be the difference between first() and reset()? I don&#039;t think there would be any. first() would need to move the internal pointer to the beginning of the array and return that element, exactly as reset() does, which is the opposite of end() which moves the internal pointer to the end of the array and returns that element.</description>
		<content:encoded><![CDATA[<p>@Will K, what would be the difference between first() and reset()? I don&#8217;t think there would be any. first() would need to move the internal pointer to the beginning of the array and return that element, exactly as reset() does, which is the opposite of end() which moves the internal pointer to the end of the array and returns that element.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Lynch</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1760</link>
		<dc:creator>Richard Lynch</dc:creator>
		<pubDate>Wed, 28 Oct 2009 04:55:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1760</guid>
		<description>array_key_exists works just fine, but it will still return TRUE even if you set the value to NULL for a given index:

$foo[42] = null;
var_dump(array_key_exists($foo, 42)); //TRUE

This can be confusing if you expect NULL to &quot;wipe out&quot; the key/value entirely.

To really get rid of it, use unset:
unset($foo[42]);

Personally, I rarely use NULL in PHP (partially because it didn&#039;t exist for so long) and simply use isset/unset.

I use NULL only when I need to clearly define a NULL value to be sent to a database layer at some point down the line.</description>
		<content:encoded><![CDATA[<p>array_key_exists works just fine, but it will still return TRUE even if you set the value to NULL for a given index:</p>
<p>$foo[42] = null;<br />
var_dump(array_key_exists($foo, 42)); //TRUE</p>
<p>This can be confusing if you expect NULL to &#8220;wipe out&#8221; the key/value entirely.</p>
<p>To really get rid of it, use unset:<br />
unset($foo[42]);</p>
<p>Personally, I rarely use NULL in PHP (partially because it didn&#8217;t exist for so long) and simply use isset/unset.</p>
<p>I use NULL only when I need to clearly define a NULL value to be sent to a database layer at some point down the line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1713</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Fri, 23 Oct 2009 18:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1713</guid>
		<description>I tested it this morning; seems to work just fine. I think you&#039;re doing it wrong.</description>
		<content:encoded><![CDATA[<p>I tested it this morning; seems to work just fine. I think you&#8217;re doing it wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohamed Almasry</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1711</link>
		<dc:creator>Mohamed Almasry</dc:creator>
		<pubDate>Fri, 23 Oct 2009 11:41:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1711</guid>
		<description>array_key_exists this function doesn&#039;t operate properly, I use it tens of times .</description>
		<content:encoded><![CDATA[<p>array_key_exists this function doesn&#8217;t operate properly, I use it tens of times .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will K</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1710</link>
		<dc:creator>Will K</dc:creator>
		<pubDate>Fri, 23 Oct 2009 11:34:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1710</guid>
		<description>@optik - functions such as end(), next(), prev() change the internal array pointer.

So current() will get the first element until any of the above functions are called, a reset() would then be required. Ideally there should be a first() function!</description>
		<content:encoded><![CDATA[<p>@optik &#8211; functions such as end(), next(), prev() change the internal array pointer.</p>
<p>So current() will get the first element until any of the above functions are called, a reset() would then be required. Ideally there should be a first() function!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: optik</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1695</link>
		<dc:creator>optik</dc:creator>
		<pubDate>Thu, 22 Oct 2009 08:00:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1695</guid>
		<description>@Oscar - end() for last element and for first? reset() - some php functions are very badly designed</description>
		<content:encoded><![CDATA[<p>@Oscar &#8211; end() for last element and for first? reset() &#8211; some php functions are very badly designed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric B</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1694</link>
		<dc:creator>Eric B</dc:creator>
		<pubDate>Thu, 22 Oct 2009 05:11:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1694</guid>
		<description>Another interesting thing about array_merge() is that it re-indexes the arrays. You can pass it just one array to have the indexes reset.

$test = array(&#039;first&#039;, &#039;second&#039;, &#039;third&#039;);
unset($test[1]);
$test = array_merge($test);

&#039;first&#039; is now $test[0], &#039;third&#039; is now $test[1].</description>
		<content:encoded><![CDATA[<p>Another interesting thing about array_merge() is that it re-indexes the arrays. You can pass it just one array to have the indexes reset.</p>
<p>$test = array(&#8216;first&#8217;, &#8217;second&#8217;, &#8216;third&#8217;);<br />
unset($test[1]);<br />
$test = array_merge($test);</p>
<p>&#8216;first&#8217; is now $test[0], &#8216;third&#8217; is now $test[1].</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve High</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1693</link>
		<dc:creator>Steve High</dc:creator>
		<pubDate>Thu, 22 Oct 2009 03:47:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1693</guid>
		<description>My favorite is array_map in conjunction with create_function

...
$arrayOfIntegers = array_map(create_function(&#039;$x&#039;, &#039;return intval($x);&#039;), $arrayOfIntegerStrings);

...
As far as array manipulation is concerned, PHP is the bee&#039;s knees ;)</description>
		<content:encoded><![CDATA[<p>My favorite is array_map in conjunction with create_function</p>
<p>&#8230;<br />
$arrayOfIntegers = array_map(create_function(&#8216;$x&#8217;, &#8216;return intval($x);&#8217;), $arrayOfIntegerStrings);</p>
<p>&#8230;<br />
As far as array manipulation is concerned, PHP is the bee&#8217;s knees ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oscar</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1689</link>
		<dc:creator>Oscar</dc:creator>
		<pubDate>Wed, 21 Oct 2009 18:56:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1689</guid>
		<description>I&#039;d also add that array_reverse and array_diff  can be quite handy too.</description>
		<content:encoded><![CDATA[<p>I&#8217;d also add that array_reverse and array_diff  can be quite handy too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oscar</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1688</link>
		<dc:creator>Oscar</dc:creator>
		<pubDate>Wed, 21 Oct 2009 18:55:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1688</guid>
		<description>@robin - thanks, I didn&#039;t know to use end() that way.  I knew about those others too so my first though was to abuse them.</description>
		<content:encoded><![CDATA[<p>@robin &#8211; thanks, I didn&#8217;t know to use end() that way.  I knew about those others too so my first though was to abuse them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1687</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Wed, 21 Oct 2009 18:37:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1687</guid>
		<description>Hm. My example was stripped out :(

$fruits = array(&#039;apple&#039;, &#039;banana&#039;, &#039;cranberry&#039;);
echo end($fruits); // cranberry

(copy-paste from http://ua2.php.net/end)</description>
		<content:encoded><![CDATA[<p>Hm. My example was stripped out :(</p>
<p>$fruits = array(&#8216;apple&#8217;, &#8216;banana&#8217;, &#8216;cranberry&#8217;);<br />
echo end($fruits); // cranberry</p>
<p>(copy-paste from <a href="http://ua2.php.net/end)" rel="nofollow">http://ua2.php.net/end)</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1686</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Wed, 21 Oct 2009 18:34:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1686</guid>
		<description>@omerida You probably know this already, but you can also grab the last element from an array without popping it using the end() function. However, it does change the internal pointer in the array (but doesn&#039;t remove the item).

</description>
		<content:encoded><![CDATA[<p>@omerida You probably know this already, but you can also grab the last element from an array without popping it using the end() function. However, it does change the internal pointer in the array (but doesn&#8217;t remove the item).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Turland</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1685</link>
		<dc:creator>Matthew Turland</dc:creator>
		<pubDate>Wed, 21 Oct 2009 17:02:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1685</guid>
		<description>Don&#039;t forget implode/explode for converting strings to arrays and vice versa. I&#039;ve always said that those two are the duct tape and WD40 of PHP. :)</description>
		<content:encoded><![CDATA[<p>Don&#8217;t forget implode/explode for converting strings to arrays and vice versa. I&#8217;ve always said that those two are the duct tape and WD40 of PHP. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oscar</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1683</link>
		<dc:creator>Oscar</dc:creator>
		<pubDate>Wed, 21 Oct 2009 14:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1683</guid>
		<description>Great Article - Here are my favorites:
array_filter - by default removes empty elements, but you can pass it a callback to filter
array_chunk - partitions an array
uasort - sorts an array and keeps they keys intact.

And also, to get the last value from an array without modifying it, i use this trick

$last = array_pop(array_values($my_array));</description>
		<content:encoded><![CDATA[<p>Great Article &#8211; Here are my favorites:<br />
array_filter &#8211; by default removes empty elements, but you can pass it a callback to filter<br />
array_chunk &#8211; partitions an array<br />
uasort &#8211; sorts an array and keeps they keys intact.</p>
<p>And also, to get the last value from an array without modifying it, i use this trick</p>
<p>$last = array_pop(array_values($my_array));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/five-cool-php-array-functions/#comment-1682</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Wed, 21 Oct 2009 14:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=887#comment-1682</guid>
		<description>I wanted to present some basic array functions that I often see duplicated in custom PHP code. That&#039;s why I picked the five I did. Thanks for your comment!</description>
		<content:encoded><![CDATA[<p>I wanted to present some basic array functions that I often see duplicated in custom PHP code. That&#8217;s why I picked the five I did. Thanks for your comment!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
