<?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>Dan Conley &#187; PHP</title>
	<atom:link href="http://www.danconley.net/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danconley.net</link>
	<description>He&#039;s just zis guy, you know?</description>
	<lastBuildDate>Thu, 01 Jul 2010 17:05:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>I&#8217;m sure this is bad practice somehow</title>
		<link>http://www.danconley.net/2009/09/im-sure-this-is-bad-practice-somehow/</link>
		<comments>http://www.danconley.net/2009/09/im-sure-this-is-bad-practice-somehow/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 17:54:35 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.danconley.net/?p=112</guid>
		<description><![CDATA[If you don&#8217;t know PHP, you can safely ignore this. I had been using the following code to get rows out of a database (it&#8217;s with Oracle, but I&#8217;m sure mysql_fetch_assoc() would work just as well for these): while ($row = oci_fetch_array($result)) { $whatever[] = $row[]; } But then it hit me: if I&#8217;m already [...]]]></description>
			<content:encoded><![CDATA[<p>If you don&#8217;t know PHP, you can safely ignore this.</p>
<p>I had been using the following code to get rows out of a database (it&#8217;s with Oracle, but I&#8217;m sure mysql_fetch_assoc() would work just as well for these):</p>
<pre>while ($row = oci_fetch_array($result)) {
    $whatever[] = $row[];
}</pre>
<p>But then it hit me: if I&#8217;m already fetching the next row of results in the while() statement, and only copying the results into another array, couldn&#8217;t I compact the code more? I rushed to that old sandbox of mine, test.php, and tried:</p>
<pre>while ($whatever[] = oci_fetch_array($result));</pre>
<p>And by gum, it worked.</p>
<p>I&#8217;m assuming there will be one of two reactions from people who read this far:</p>
<ol>
<li>Well, <em>yeah</em>.</li>
<li>That&#8217;s horribly bad practice because&#8230;</li>
</ol>
<p>But considering I&#8217;m entirely self-taught, I&#8217;m fairly proud of myself. And if I shouldn&#8217;t be, please do let me know.</p>
<p><strong>Edit</strong>: And there it is! Since the loop creates the new item in the array and <em>then</em> fills it with the value of oci_fetch_array, there&#8217;s always an empty value at the end that messes with foreach(). It was a fun idea while it lasted, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danconley.net/2009/09/im-sure-this-is-bad-practice-somehow/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
