<?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 Reference Book Blog</title>
	<atom:link href="http://www.phpreferencebook.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpreferencebook.com</link>
	<description>PHP Reference: Beginner to Intermediate PHP5</description>
	<lastBuildDate>Sat, 07 Apr 2012 17:59:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Search Speed: Isset vs In_array vs MySQL Query</title>
		<link>http://www.phpreferencebook.com/tips/isset-in_array-mysql/</link>
		<comments>http://www.phpreferencebook.com/tips/isset-in_array-mysql/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 03:07:33 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[in_array]]></category>
		<category><![CDATA[isset]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=445</guid>
		<description><![CDATA[As databases and visitors grow, sometimes &#8216;old code&#8217; doesn&#8217;t work like it use to: it takes too long or times out for exceeding the maximum time allowed by your server for PHP execution. On a MySQL table with 30,000 rows (not too many), the query was checking one column for &#60;3 and then matching a [...]]]></description>
			<content:encoded><![CDATA[<p>As databases and visitors grow, sometimes &#8216;old code&#8217; doesn&#8217;t work like it use to: it takes too long or times out for exceeding the maximum time allowed by your server for PHP execution. On a MySQL table with 30,000 rows (not too many), the query was checking one column for &lt;3 and then matching a long list (10,000) of values in a second column using a long WHERE column2=&#8217;value&#8217; clause. Here is an example of the table:</p>
<pre>
|--column1--|--column2--|
|     0     |    1234   |
|     3     |    5678   |
-------------------------
</pre>
<p>A MySQL query took a while, but didn&#8217;t time out when the list of WHERE column2=&#8217;value&#8217; was less than 7000, but it was just overwhelmed at 10,000. Okay, fine, time to go to phase two: <strong>in_array()</strong>.<br />
There was an existing array of values for column2, so I could simply pull a list of &lt;3 from MySQL (quick) and then loop through (foreach) each of the results and check whether they are <strong>in_array()</strong> for the original source. If they were, just save them to a brand new array that I&#8217;ll use to work further through the problem. For clarification, that means that the system should go through 10,000+ iterations and check if each value is <strong>in_array()</strong>. If you had not already guessed, this was disastrous. <strong>In_Array()</strong> is very inefficient, and if you are dealing with an array that is more than 100 or so values, you&#8217;ll quickly learn this fact. So what to do? Use <strong>isset()</strong>.<br />
<strong>Isset()</strong>, as a function, is incredibly fast. It only checks whether something exists, and is a great way to check for whether something exists in an array. However, the trick is using <strong>isset()</strong> will look at the KEYS, while in_array() will look at the VALUES. Is that problem? Not if you build the original array as <strong>[value]=&gt;value</strong> (set the KEY and VALUE the same). Now, as long as your values are valid keys and unique, this won&#8217;t be a problem. Then, you can use a foreach loop to check whether it is found in the original array. Here is some sample code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array_source</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'abc'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'abc'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'def'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'def'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'ghi'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'ghi'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$array_results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'xyz'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'ghi'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_results</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_source</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//fast</span>
    <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//if found, save it to a fresh array</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>What was the final result? The query, run 6 different times for 6 different data sets, went from a total execution time exceeding 2 minutes (MySQL), to not working at all (in_array), to <strong>0.18 seconds</strong>. Yes, less than one second! That is the power for checking whether a value is set when comparing arrays. <strong>Isset()</strong> is even faster by a notable amount when compared to <strong>array_diff()</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/tips/isset-in_array-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ltrim() and rtrim() function examples</title>
		<link>http://www.phpreferencebook.com/corrections/ltrim-and-rtrim-function-examples/</link>
		<comments>http://www.phpreferencebook.com/corrections/ltrim-and-rtrim-function-examples/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 21:45:42 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Corrections]]></category>
		<category><![CDATA[ltrim]]></category>
		<category><![CDATA[rtrim]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=438</guid>
		<description><![CDATA[The examples presented for both ltrim() and rtrim() are accurate in their results, however the stated functions used is actually trim(). Thus, here are the corrected examples: ltrim() $string = &#34; \n Hello World!&#34;; echo ltrim&#40;$string&#41;; Hello World! echo ltrim&#40;$string, &#34; \nA..Ha..z!&#34;&#41;; // All capital letters between A and H, all lowercase letters, exclamation point, [...]]]></description>
			<content:encoded><![CDATA[<p>The examples presented for both ltrim() and rtrim() are accurate in their results, however the stated functions used is actually trim(). Thus, here are the corrected examples:<br />
<strong>ltrim()</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;  <span style="color: #000099; font-weight: bold;">\n</span> Hello World!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">ltrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<blockquote><p>Hello World!</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #990000;">ltrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; <span style="color: #000099; font-weight: bold;">\n</span>A..Ha..z!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// All capital letters between A and H, all lowercase letters, exclamation point, space, and newline</span></pre></div></div>

<blockquote><p>World!</p></blockquote>
<p><strong>rtrim()</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;!Hello World42! <span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<blockquote><p>!Hello World42!</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; <span style="color: #000099; font-weight: bold;">\t</span>!0..9&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Range included is all numbers between 0 and 9, tab, space, and exclamation point.</span></pre></div></div>

<blockquote><p>!Hello World</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/corrections/ltrim-and-rtrim-function-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>array_flip() function typo</title>
		<link>http://www.phpreferencebook.com/corrections/array_flip-function-typo/</link>
		<comments>http://www.phpreferencebook.com/corrections/array_flip-function-typo/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 21:32:06 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Corrections]]></category>
		<category><![CDATA[array_flip]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=435</guid>
		<description><![CDATA[A really minor correction. In the first sentence describing the function, it states: Returns an array with they keys&#8230; It should read: Returns an array with the keys&#8230;]]></description>
			<content:encoded><![CDATA[<p>A really minor correction. In the first sentence describing the function, it states:</p>
<blockquote><p>Returns an array with they keys&#8230;</p></blockquote>
<p>It should read:</p>
<blockquote><p>Returns an array with <strong>the</strong> keys&#8230;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/corrections/array_flip-function-typo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Update Multiple Columns Query</title>
		<link>http://www.phpreferencebook.com/tips/mysql-update-multiple-columns-query/</link>
		<comments>http://www.phpreferencebook.com/tips/mysql-update-multiple-columns-query/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 21:19:57 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=432</guid>
		<description><![CDATA[While the book only includes a single example on page 117 for the MySQL UPDATE query, it should have also included an example of a multiple column UPDATE. Here is an example: UPDATE table SET column1=&#8217;newvalue&#8217;,column2=&#8217;nextvalue&#8217; WHERE column3=&#8217;value&#8217;]]></description>
			<content:encoded><![CDATA[<p>While the book only includes a single example on page 117 for the MySQL UPDATE query, it should have also included an example of a multiple column UPDATE. Here is an example:</p>
<blockquote><p>UPDATE table SET column1=&#8217;newvalue&#8217;,column2=&#8217;nextvalue&#8217; WHERE column3=&#8217;value&#8217;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/tips/mysql-update-multiple-columns-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>preg_match()</title>
		<link>http://www.phpreferencebook.com/corrections/preg_match/</link>
		<comments>http://www.phpreferencebook.com/corrections/preg_match/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 21:09:34 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Corrections]]></category>
		<category><![CDATA[preg_match]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=428</guid>
		<description><![CDATA[(page 156-157) preg_match() In the last sentence, it includes some extraneous words: &#8221;number of matches&#8221;. It should simply read: Returns: 1 if matched, 0 if no match, and FALSE on error.]]></description>
			<content:encoded><![CDATA[<p><strong>(page 156-157)</strong><br />
preg_match()<br />
In the last sentence, it includes some extraneous words: &#8221;number of matches&#8221;. It should simply read:</p>
<blockquote><p>Returns: 1 if matched, 0 if no match, and FALSE on error.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/corrections/preg_match/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check for Common Mistakes in PHP Code</title>
		<link>http://www.phpreferencebook.com/tips/check-for-common-mistakes-in-php-code/</link>
		<comments>http://www.phpreferencebook.com/tips/check-for-common-mistakes-in-php-code/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 04:19:44 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[php errors]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=415</guid>
		<description><![CDATA[A while ago I posted an article on the 10 common PHP errors and mistakes. While this helped decipher some of the cryptic errors you get from PHP when executing your code, it doesn&#8217;t help you when the mistakes either are not caught by the PHP compiler ($variable == &#8216;hello world&#8217;; anyone?), or are tricky [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.phpreferencebook.com/wp-content/uploads/2011/04/frustrated-man.jpg" alt="frustrated man" title="frustrated man" width="240" height="160" class="alignleft size-full wp-image-417" style="margin: 0 10px 10px 10px;" />A while ago I posted an article on the 10 <a href="http://www.phpreferencebook.com/misc/php-errors-common-mistakes/">common PHP errors and mistakes</a>. While this helped decipher some of the cryptic errors you get from PHP when executing your code, it doesn&#8217;t help you when the mistakes either are not caught by the PHP compiler ($variable == &#8216;hello world&#8217;; anyone?), or are tricky to track down. Well, I finally got some spare time and decided to build something for that.</p>
<p>It is still a work in progress, but the new <a href="http://phpcodechecker.com/">PHP Code Checker</a> will not execute your code, simply scan it as a string and run a battery of tests to find these mistakes. It is only a few weeks and less than 10 hours of work in it so far, but it is already at version 0.2 and is ready to help you. There is more coming soon, so keep tabs on the site and I hope it helps you deal with those tough code problems!</p>
<p><em><a href="http://www.flickr.com/photos/zachklein/54389823/">Photo courtesy of Zach Klein</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/tips/check-for-common-mistakes-in-php-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Find Fields in Table not Found in First Table</title>
		<link>http://www.phpreferencebook.com/tips/mysql-query-not-in-exclusion-table/</link>
		<comments>http://www.phpreferencebook.com/tips/mysql-query-not-in-exclusion-table/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 17:49:28 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=358</guid>
		<description><![CDATA[It took a ton of googling, and it was really hard to find the answer. I had two tables, and wanted to do a MySQL Query that seems like a NOT IN between two tables. There are two tables with one unique field that is the same between the tables. The goal is to find [...]]]></description>
			<content:encoded><![CDATA[<p>It took a ton of googling, and it was really hard to find the answer. I had two tables, and wanted to do a MySQL Query that seems like a NOT IN between two tables. There are two tables with one unique field that is the same between the tables. The goal is to find the rows in the second table that are <strong>not</strong> found in the first table based upon the similar field.</p>
<p>I could attempt to explain this, but someone has already done a very good job of this, so I&#8217;d rather just provide a link to their content. The post is from the author of &#8220;High Performance MySQL&#8221;, Baron Schwartz, and covers writing an <a href="http://www.xaprb.com/blog/2005/09/23/how-to-write-a-sql-exclusion-join/">SQL Exclusion Join</a>. The key area of interest is the section on LEFT OUTER joins. He offers this example query:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> apples<span style="color: #66cc66;">.</span>Variety
<span style="color: #993333; font-weight: bold;">FROM</span> apples
    <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> oranges
        <span style="color: #993333; font-weight: bold;">ON</span> apples<span style="color: #66cc66;">.</span>Price <span style="color: #66cc66;">=</span> oranges<span style="color: #66cc66;">.</span>Price
<span style="color: #993333; font-weight: bold;">WHERE</span> oranges<span style="color: #66cc66;">.</span>Price <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NULL</span></pre></div></div>

<p>When in doubt, find someone smarter to answer the question for you. <img src='http://www.phpreferencebook.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Thanks Baron!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/tips/mysql-query-not-in-exclusion-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: getcwd() for Contents of Current Directory</title>
		<link>http://www.phpreferencebook.com/tips/getcwd-scandir-get-display-contents-current-directory/</link>
		<comments>http://www.phpreferencebook.com/tips/getcwd-scandir-get-display-contents-current-directory/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 14:00:52 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[getcwd]]></category>
		<category><![CDATA[scandir]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=352</guid>
		<description><![CDATA[The getcwd() function is short for &#8216;GET Current Working Directory&#8217;. This can easily be combined with the scandir() function which returns an array of all the files and directories inside the specified directory. This tip was excluded from the book as an oversight. &#160; A quick way to get a list of all the contents [...]]]></description>
			<content:encoded><![CDATA[<p>The getcwd() function is short for &#8216;GET Current Working Directory&#8217;. This can easily be combined with the scandir() function which returns an array of all the files and directories inside the specified directory. This tip was excluded from the book as an oversight.<br />
&nbsp;<br />
A quick way to get a list of all the contents of the current directory is to use the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> preprint<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt; pre&gt;'</span><span style="color: #339933;">.</span><span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt; /pre&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getcwd</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
preprint<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// nicely formatted display of the array</span></pre></div></div>

<p>&nbsp;<br />
Of course, you can skip the print/echo portion if you don&#8217;t wish to display the contents and just use the array to perform other checks, but you get the idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/tips/getcwd-scandir-get-display-contents-current-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>fwrite() has a Double Tip that is Misplaced</title>
		<link>http://www.phpreferencebook.com/corrections/fwrite-double-tip-misplaced/</link>
		<comments>http://www.phpreferencebook.com/corrections/fwrite-double-tip-misplaced/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 12:00:09 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Corrections]]></category>
		<category><![CDATA[fread]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[fwrite]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=346</guid>
		<description><![CDATA[On page 131, the fwrite() function has a TIP that reads: &#160; To read the entire file into a string, use the function filesize(). // file.txt contains the sentence: Hello World! $filename = 'file.txt'; $file = fopen&#40;$filename, 'r'&#41;; $string = fread&#40; $file, filesize&#40;$filename&#41; &#41;; var_dump&#40;$string&#41;; // file.txt now contains at the end: Hello World! You&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>On page 131, the fwrite() function has a TIP that reads:<br />
&nbsp;<br />
<strong>To read the entire file into a string, use the function filesize().</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// file.txt contains the sentence: Hello World!</span>
<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'file.txt'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// file.txt now contains at the end: Hello World!</span></pre></div></div>

<p>You&#8217;ll notice that this is the same tip as fread() and doesn&#8217;t belong. It should be considered &#8216;removed&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/corrections/fwrite-double-tip-misplaced/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Index: array_combine() array_key_exists()</title>
		<link>http://www.phpreferencebook.com/corrections/index-preg_match_all-array_combine-chdir-array_key_exists/</link>
		<comments>http://www.phpreferencebook.com/corrections/index-preg_match_all-array_combine-chdir-array_key_exists/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 08:04:18 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Corrections]]></category>
		<category><![CDATA[array_combine]]></category>
		<category><![CDATA[array_key_exists]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[preg_match_all]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=337</guid>
		<description><![CDATA[Some quick corrections for the Function Index: pg. 162 preg_match_all: 157-158 pg. 161 array_combine: 73 array_key_exists: 79-80]]></description>
			<content:encoded><![CDATA[<p>Some quick corrections for the Function Index:</p>
<h3>pg. 162</h3>
<p>preg_match_all: <strong>157-158</strong></p>
<h3>pg. 161</h3>
<p>array_combine: <strong>73</strong><br />
array_key_exists: <strong>79-80</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/corrections/index-preg_match_all-array_combine-chdir-array_key_exists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 3.221 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-18 00:15:42 -->
<!-- Compression = gzip -->
