<?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 Arrays Unleashed</title> <atom:link href="http://brenelz.com/blog/php-arrays-unleashed/feed/" rel="self" type="application/rss+xml" /><link>http://brenelz.com/blog/php-arrays-unleashed/</link> <description>a winnipeg website design company.</description> <lastBuildDate>Thu, 29 Jul 2010 18:34:25 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>By: Barry</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-4854</link> <dc:creator>Barry</dc:creator> <pubDate>Mon, 28 Dec 2009 21:25:49 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-4854</guid> <description>I just found this page via a &lt;a href=&quot;http://net.tutsplus.com/articles/web-roundups/120-tips-tricks-and-tuts-from-2009-worth-your-time/&quot; rel=&quot;nofollow&quot;&gt;net.tutsplus.com post&lt;/a&gt;. It&#039;s nice roundup of info on PHP arrays.I did notice that in the &quot;Accessing Indexed Array Values&quot; section you say that &quot;value-2&quot; corresponds to index key 3 when it should say it corresponds to index key 1.You might want to fix that, zero indexing trips people up enough when they&#039;re getting started.</description> <content:encoded><![CDATA[<p>I just found this page via a <a href="http://net.tutsplus.com/articles/web-roundups/120-tips-tricks-and-tuts-from-2009-worth-your-time/" rel="nofollow">net.tutsplus.com post</a>. It&#8217;s nice roundup of info on PHP arrays.</p><p>I did notice that in the &#8220;Accessing Indexed Array Values&#8221; section you say that &#8220;value-2&#8243; corresponds to index key 3 when it should say it corresponds to index key 1.</p><p>You might want to fix that, zero indexing trips people up enough when they&#8217;re getting started.</p> ]]></content:encoded> </item> <item><title>By: web design company manager</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1289</link> <dc:creator>web design company manager</dc:creator> <pubDate>Tue, 12 May 2009 16:05:00 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1289</guid> <description>Very interesting and useful information. I&#039;m not so good in programming so I will give a link to our developer to explain me some details.</description> <content:encoded><![CDATA[<p>Very interesting and useful information. I&#8217;m not so good in programming so I will give a link to our developer to explain me some details.</p> ]]></content:encoded> </item> <item><title>By: dogwood</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1288</link> <dc:creator>dogwood</dc:creator> <pubDate>Fri, 24 Apr 2009 18:05:49 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1288</guid> <description>Fredrik --For those of us who will never be as smart as a &quot;fredrik,&quot; tutorials and explanations like this are very helpful and appreciated.</description> <content:encoded><![CDATA[<p>Fredrik &#8211;</p><p>For those of us who will never be as smart as a &#8220;fredrik,&#8221; tutorials and explanations like this are very helpful and appreciated.</p> ]]></content:encoded> </item> <item><title>By: BTM</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1287</link> <dc:creator>BTM</dc:creator> <pubDate>Fri, 24 Apr 2009 16:43:29 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1287</guid> <description>Hi there.2 things first ;-)1) Your bloging software looks hungry - you&#039;ve got some $ missing in:foreach (array as $value) (...)2) While it&#039;s true that you can declare arrays by simply calling $newArray[] = &#039;some value&#039;; witch will give you a nice 1 element array, it&#039;s syntax-wise correct to declare the variable as array by doing:$newArray = array(); $newArray[] = &#039;some value&#039;;Else you&#039;ll get an error at E_ALL error reporting level.Aside from those two things - great explanation for the beginners among us :)</description> <content:encoded><![CDATA[<p>Hi there.</p><p>2 things first <img src='http://cdnwww.brenelz.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p><p>1) Your bloging software looks hungry &#8211; you&#8217;ve got some $ missing in:</p><p>foreach (array as $value) (&#8230;)</p><p>2) While it&#8217;s true that you can declare arrays by simply calling $newArray[] = &#8216;some value&#8217;; witch will give you a nice 1 element array, it&#8217;s syntax-wise correct to declare the variable as array by doing:</p><p>$newArray = array();<br /> $newArray[] = &#8216;some value&#8217;;</p><p>Else you&#8217;ll get an error at E_ALL error reporting level.</p><p>Aside from those two things &#8211; great explanation for the beginners among us <img src='http://cdnwww.brenelz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: fredrik</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1286</link> <dc:creator>fredrik</dc:creator> <pubDate>Fri, 24 Apr 2009 14:13:07 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1286</guid> <description>honestly, if you think that&quot;An array is not an easy concept to grasp at first since an array has many values, or elements, and can be used in so many ways.&quot;aka. arrays are HARD, you should not freakin be in software development - if it doesnt come naturally you will always suck compared to those that it does for.</description> <content:encoded><![CDATA[<p>honestly, if you think that</p><p>&#8220;An array is not an easy concept to grasp at first since an array has many values, or elements, and can be used in so many ways.&#8221;</p><p>aka. arrays are HARD, you should not freakin be in software development &#8211; if it doesnt come naturally you will always suck compared to those that it does for.</p> ]]></content:encoded> </item> <item><title>By: shane sponagle</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1290</link> <dc:creator>shane sponagle</dc:creator> <pubDate>Tue, 21 Apr 2009 02:47:04 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1290</guid> <description>Jason Lengstorf: Thanks for catching that error and pointing out the solution. I thought I had tested all the code but that one made it by and also made it through the proofing. Ooops :)</description> <content:encoded><![CDATA[<p>Jason Lengstorf: Thanks for catching that error and pointing out the solution. I thought I had tested all the code but that one made it by and also made it through the proofing. Ooops <img src='http://cdnwww.brenelz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Jason Lengstorf</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1291</link> <dc:creator>Jason Lengstorf</dc:creator> <pubDate>Tue, 21 Apr 2009 01:52:32 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1291</guid> <description>Great work, Shane!I did want to point out, however, that there&#039;s a mistake in the nested foreach loops. The following:foreach($myMenu as $key =&gt; $val){ foreach($val as $k =&gt; $v){ $url = $k; $link = $v; } $output .= &quot;&lt;a href=\&quot;$url\&quot; title=\&quot;$key\&quot; id=\&quot;$key\&quot;&gt;$link&lt;/a&gt;&lt;br /&gt;\n&quot;; }echo $output;The above doesn&#039;t generate the actual URL in the href attribute (which is wrong in your output example as well). Instead, it inserts the second array key:&lt;a href=&quot;text&quot; title=&quot;home&quot; id=&quot;home&quot;&gt;Home Page&lt;/a&gt;&lt;br /&gt;This is because the second foreach loop is overwriting variables, first storing $url=&quot;url&quot; and $link=&quot;home.html&quot;, then storing $url=&quot;text&quot; and $link=&quot;Home Page&quot;.This can be corrected by using the key to create &lt;a href=&quot;http://www.php.net/manual/en/language.variables.variable.php&quot; rel=&quot;nofollow&quot;&gt;variable variables&lt;/a&gt; that contain the value from the array.The nested loops below will generate the desired output.foreach($myMenu as $key =&gt; $val){ foreach($val as $k =&gt; $v){ $$k = $v; } $output .= &quot;&lt;a href=\&quot;$url\&quot; title=\&quot;$key\&quot; id=\&quot;$key\&quot;&gt;$text&lt;/a&gt;&lt;br /&gt;\n&quot;; }echo $output;Everything else looks solid. Great read!(NOTE: I&#039;m crossing my fingers and hoping that HTML tags work in comments, because I used a bunch of them. My apologies if this comment comes out all jacked up.)</description> <content:encoded><![CDATA[<p>Great work, Shane!</p><p>I did want to point out, however, that there&#8217;s a mistake in the nested foreach loops. The following:</p><p>foreach($myMenu as $key =&gt; $val){<br /> foreach($val as $k =&gt; $v){<br /> $url = $k;<br /> $link = $v;<br /> }<br /> $output .= &#8220;&lt;a href=\&#8221;$url\&#8221; title=\&#8221;$key\&#8221; id=\&#8221;$key\&#8221;&gt;$link&lt;/a&gt;&lt;br /&gt;\n&#8221;;<br /> }</p><p>echo $output;</p><p>The above doesn&#8217;t generate the actual URL in the href attribute (which is wrong in your output example as well). Instead, it inserts the second array key:</p><p>&lt;a href=&#8221;text&#8221; title=&#8221;home&#8221; id=&#8221;home&#8221;&gt;Home Page&lt;/a&gt;&lt;br /&gt;</p><p>This is because the second foreach loop is overwriting variables, first storing $url=&#8221;url&#8221; and $link=&#8221;home.html&#8221;, then storing $url=&#8221;text&#8221; and $link=&#8221;Home Page&#8221;.</p><p>This can be corrected by using the key to create <a href="http://www.php.net/manual/en/language.variables.variable.php" rel="nofollow">variable variables</a> that contain the value from the array.</p><p>The nested loops below will generate the desired output.</p><p>foreach($myMenu as $key =&gt; $val){<br /> foreach($val as $k =&gt; $v){<br /> $$k = $v;<br /> }<br /> $output .= &#8220;&lt;a href=\&#8221;$url\&#8221; title=\&#8221;$key\&#8221; id=\&#8221;$key\&#8221;&gt;$text&lt;/a&gt;&lt;br /&gt;\n&#8221;;<br /> }</p><p>echo $output;</p><p>Everything else looks solid. Great read!</p><p>(NOTE: I&#8217;m crossing my fingers and hoping that HTML tags work in comments, because I used a bunch of them. My apologies if this comment comes out all jacked up.)</p> ]]></content:encoded> </item> <item><title>By: Drew Douglass</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1292</link> <dc:creator>Drew Douglass</dc:creator> <pubDate>Mon, 20 Apr 2009 21:07:05 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1292</guid> <description>I really wish this article would have been around when I started learning php, arrays took me a while to get the hang of.I think it really takes a while using php until you realize how powerful and useful they are, from error reporting/displaying, to handling xml feeds, and results from MySQL.Also, I really laughed when Mary said &#039;they always throw her for a loop&#039;, so many programming puns could be made, I just don&#039;t know where to start. You know I love you Mary!Great article Shane :)</description> <content:encoded><![CDATA[<p>I really wish this article would have been around when I started learning php, arrays took me a while to get the hang of.</p><p>I think it really takes a while using php until you realize how powerful and useful they are, from error reporting/displaying, to handling xml feeds, and results from MySQL.</p><p>Also, I really laughed when Mary said &#8216;they always throw her for a loop&#8217;, so many programming puns could be made, I just don&#8217;t know where to start. You know I love you Mary!</p><p>Great article Shane <img src='http://cdnwww.brenelz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: mary</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1293</link> <dc:creator>mary</dc:creator> <pubDate>Mon, 20 Apr 2009 19:31:17 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1293</guid> <description>Thank you for this. PHP arrays is one of those things I aim to master, and which I&#039;ve figured out is absolutely crucial to my budding PHP skills, but they always throw me for a loop.  This is an excellent writeup that I know I&#039;ll bookmark and revisit often!thanks much Shane!mary</description> <content:encoded><![CDATA[<p>Thank you for this. PHP arrays is one of those things I aim to master, and which I&#8217;ve figured out is absolutely crucial to my budding PHP skills, but they always throw me for a loop.  This is an excellent writeup that I know I&#8217;ll bookmark and revisit often!</p><p>thanks much Shane!</p><p>mary</p> ]]></content:encoded> </item> <item><title>By: Kevin</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1294</link> <dc:creator>Kevin</dc:creator> <pubDate>Mon, 20 Apr 2009 18:19:10 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1294</guid> <description>Still learning PHP, arrays may come later. Familiar enough with them to be dangerous, so this will be great information later. Thanks!</description> <content:encoded><![CDATA[<p>Still learning PHP, arrays may come later. Familiar enough with them to be dangerous, so this will be great information later. Thanks!</p> ]]></content:encoded> </item> <item><title>By: shane sponagle</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1295</link> <dc:creator>shane sponagle</dc:creator> <pubDate>Mon, 20 Apr 2009 14:40:44 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1295</guid> <description>Yeah, the more I use arrays the more I love them..and the way php handles arrays is great. I had a heck of a time figuring out how to work with them at first but now I think every script will use at least one array :)</description> <content:encoded><![CDATA[<p>Yeah, the more I use arrays the more I love them..and the way php handles arrays is great. I had a heck of a time figuring out how to work with them at first but now I think every script will use at least one array <img src='http://cdnwww.brenelz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Isaac Van Name</title><link>http://brenelz.com/blog/php-arrays-unleashed/comment-page-1/#comment-1296</link> <dc:creator>Isaac Van Name</dc:creator> <pubDate>Mon, 20 Apr 2009 14:06:50 +0000</pubDate> <guid isPermaLink="false">http://www.brenelz.com/blog/?p=945#comment-1296</guid> <description>Great piece on PHP arrays! I&#039;ve coded in a number of languages, and still find that PHP handles arrays best of all. The array functions its core comes with are fantastic.</description> <content:encoded><![CDATA[<p>Great piece on PHP arrays! I&#8217;ve coded in a number of languages, and still find that PHP handles arrays best of all. The array functions its core comes with are fantastic.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 4/21 queries in 0.124 seconds using disk
Content Delivery Network via cdnwww.brenelz.com

Served from: brenelz.com @ 2010-08-01 10:31:06 -->