<?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, 03 Jul 2010 04:04:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<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>
		<item>
		<title>Fixing strtotime -1 month</title>
		<link>http://www.phpreferencebook.com/tips/fixing-strtotime-1-month/</link>
		<comments>http://www.phpreferencebook.com/tips/fixing-strtotime-1-month/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 18:03:26 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[strtotime]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=325</guid>
		<description><![CDATA[There is a bug for strtotime() when you are on the last day of a month that has 31 days in it. The function, strotime(&#8216;-1 month&#8217;) will return the beginning of the current month, or put another way, 30 days prior. Needless to say, this is annoying. However, it doesn&#8217;t come up very often, and [...]]]></description>
			<content:encoded><![CDATA[<p>There is a bug for <strong>strtotime()</strong> when you are on the last day of a month that has 31 days in it. The function, <strong>strotime(&#8216;-1 month&#8217;)</strong> will return the beginning of the current month, or put another way, 30 days prior. Needless to say, this is annoying. However, it doesn&#8217;t come up very often, and there is a way to fix things: by rolling back the clock 3 extra days. I ran into this problem on a different personal project, and wrote the following function to address the issue. Whenever using strtotime() and negative months, switch in strtotimefix() instead:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> strtotimefix<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span><span style="color: #000088;">$timestamp</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</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: #000088;">$timestamp</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000088;">$timestamp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-1 month'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$timestamp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-3 days'</span><span style="color: #339933;">,</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$timestamp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$strtotime</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$strtotime</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So what&#8217;s happening? Basically, the function will check if the numeric month is the same between the current month and the month through &#8216;-1 month&#8217;. If so, it subtracts 3 days from the current timestamp, then runs through the strtotime function using the new timestamp. If everything is fine, nothing is altered, so you don&#8217;t have to worry that using the strtotimefix() function will break a perfectly normal strtotime(&#8216;-1 month&#8217;) call. Be advised that if you are not doing a call with &#8216;-x month&#8217;, the function will return an incorrect timestamp by 3 days (I hope to update it to be self-aware and only &#8216;fix&#8217; when the bug would be introduced).</p>
<p><strong>Updated on March 30, 2010:</strong><br />
Changed it to -3 days to deal with February/March.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/tips/fixing-strtotime-1-month/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SEOMoz &#8211; Third-Party Affiliate Programs</title>
		<link>http://www.phpreferencebook.com/misc/roll-your-own-affiliate-program/</link>
		<comments>http://www.phpreferencebook.com/misc/roll-your-own-affiliate-program/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 23:45:16 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[seomoz]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=320</guid>
		<description><![CDATA[The following is a translation of ASP code to PHP for the following SEOMoz post: Third-Party Affiliate Programs: Roll Your Own Instead 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 &#60;?php $AffiliateID = trim&#40;$_GET&#91;'affid'&#93;&#41;; &#160; $CanonicalURL = $_SERVER&#91;'SERVER_NAME'&#93; . $_SERVER&#91;'SCRIPT_NAME'&#93;; &#160; if &#40;strlen&#40;$AffiliateID&#41; &#62; 0&#41; &#123; $CanonicalURL [...]]]></description>
			<content:encoded><![CDATA[<p>The following is a translation of ASP code to PHP for the following SEOMoz post:<br />
<a href="http://www.seomoz.org/blog/roll-your-own-affiliate-program">Third-Party Affiliate Programs: Roll Your Own Instead</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$AffiliateID</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'affid'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$CanonicalURL</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$AffiliateID</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$CanonicalURL</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;affid=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$AffiliateID</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$CanonicalURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$CanonicalURL</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;affid=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$AffiliateID</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$CanonicalURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;AffiliateID&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$AffiliateID</span><span style="color: #339933;">,</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
...
&nbsp;
&lt;link rel=&quot;canonical&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$CanonicalURL</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/misc/roll-your-own-affiliate-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon Kindle (US Edition) now $259</title>
		<link>http://www.phpreferencebook.com/misc/amazon-kindle-us-259/</link>
		<comments>http://www.phpreferencebook.com/misc/amazon-kindle-us-259/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 12:53:03 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[kindle]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=300</guid>
		<description><![CDATA[Amazon has dropped the price again on their original 6&#8243; U.S. Kindle ebook reader to $259. They have also introduced a discount on their International Wireless Kindle edition making it $279. Previously, there was a Kindle price reduction of $299. Now you can carry around your reference book and more for the same weight and [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon has dropped the price again on their original 6&#8243; <a href="http://www.amazon.com/gp/product/B00154JDAI?tag=phpreferencebook-20">U.S. Kindle ebook reader</a> to <strong>$259</strong>. They have also introduced a discount on their <a href="http://www.amazon.com/gp/product/B0015T963C?tag=phpreferencebook-20">International Wireless Kindle</a> edition making it <strong>$279</strong>. Previously, there was a Kindle price reduction of $299. Now you can carry around your reference book and more for the same weight and dimensions as a copy of just the PHP reference book! Sleek and lightweight, <a href="http://www.amazon.com/gp/product/B00154JDAI?tag=phpreferencebook-20">Kindle</a> is as thin as a typical magazine and holds over 1,500 books.  An advanced display reads like real paper and boasts 16 shades of gray for clear text and crisp images. The current generation has improved page refresh: faster page flips as the e-ink changes the entire page. Even better, small changes to the page don&#8217;t require a full refresh (the black-white flash) of the entire page!</p>
<p>A kindle version of PHP Reference: Beginner to Intermediate PHP5 is available for <a href="http://www.amazon.com/gp/product/B001B3HULC?ie=UTF8&#038;tag=phpreferencebook-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=B001B3HULC">$8.99 through Amazon.com</a>, at just over half the price of the main book!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/misc/amazon-kindle-us-259/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Common Regular Expressions</title>
		<link>http://www.phpreferencebook.com/tips/common-regular-expressions/</link>
		<comments>http://www.phpreferencebook.com/tips/common-regular-expressions/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 05:38:13 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[preg_match]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=278</guid>
		<description><![CDATA[I&#8217;ve gotten better and more comfortable with regular expressions as time has passed, and sometimes I spend timing wading through google for some common regular expressions I want to put into use, because I&#8217;m sure someone has already created it. Well, this isn&#8217;t always true (or easy to find), so I decided to collect some [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gotten better and more comfortable with regular expressions as time has passed, and sometimes I spend timing wading through google for some common regular expressions I want to put into use, because I&#8217;m sure someone has already created it. Well, this isn&#8217;t always true (or easy to find), so I decided to collect some common Regular Expressions that may benefit readers. It&#8217;s a good idea to keep two things handy if you want to play with Regular Expressions yourself:</p>
<ul>
<li>A copy of the PHP book with a tab on pages 149 and 150 for common RegEx syntax</li>
<li>A link to <a href="http://regexpal.com/" target="_blank">RegExPal</a>, a color coding <a href="http://www.phpreferencebook.com/tips/regex-color-coding/">Regular Expression tester</a>.</li>
</ul>
<h1>Common Regular Expressions:</h1>
<h2>Date and Time RegEx</h2>
<p><strong>Time format (no seconds): </strong><br />
HH:MM am/pm</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#91;</span><span style="color: #208080;">012</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>\s?<span style="color: #009900;">&#40;</span>am<span style="color: #339933;">|</span>AM<span style="color: #339933;">|</span>pm<span style="color: #339933;">|</span>PM<span style="color: #009900;">&#41;</span>$</pre></div></div>

<p><strong>Date in mm/dd/yyyy format, with an option for m/d/yyyy (exclude zero&#8217;s)</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>?<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#91;</span><span style="color: #208080;">012</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span> \<span style="color: #339933;">/.-</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>?<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#91;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span> \<span style="color: #339933;">/.-</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">19</span><span style="color: #339933;">|</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span>\d\d$</pre></div></div>

<p><strong>Date in dd/mm/yyyy format, with an option for d/m/yyyy (exclude zero&#8217;s)</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>?<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#91;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span> \<span style="color: #339933;">/.-</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>?<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#91;</span><span style="color: #208080;">012</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span> \<span style="color: #339933;">/.-</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">19</span><span style="color: #339933;">|</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span>\d\d$</pre></div></div>

<h2>Demographics RegEx</h2>
<p><strong>Age in years &#8211; max 122</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>$</pre></div></div>

<p><strong>Height in Feet and Inches:</strong><br />
6&#8217;3&#8243;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #0000ff;">')?\s?([1-9]|1[01])$</span></pre></div></div>

<h2>Contact Information RegEx</h2>
<p><strong>U.S. Phone Number &#8211; parenthesis, periods, dashes, and spaces are allowed:</strong><br />
(123) 456.7890</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>\<span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span>\<span style="color: #009900;">&#41;</span>\s?<span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">-</span>\s\<span style="color: #339933;">.</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">-</span>\s\<span style="color: #339933;">.</span><span style="color: #009900;">&#93;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#125;</span>$</pre></div></div>

<p><strong>U.S. Zip Code &#8211; 5 or 9 digit with dash</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>\<span style="color: #339933;">-</span><span style="color: #009900;">&#93;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span>$</pre></div></div>

<p><strong>Email Address &#8211; (use preg_match) credit goes to <a href="http://fightingforalostcause.net/misc/2006/compare-email-regex.php" target="_blank">fightingforalostcause.net</a></strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">/</span>^<span style="color: #009900;">&#91;</span><span style="color: #339933;">-</span>_a<span style="color: #339933;">-</span>z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span>\<span style="color: #0000ff;">'+*$^&amp;%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&amp;%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?&lt;![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD</span></pre></div></div>

<h2>Currency RegEx</h2>
<p><strong>Currency &#8211; U.S. Dollars and Cents with commas for multiple&#8217;s of 1000 and a period for the decimal:</strong><br />
$12,000.23</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^\$?<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#41;</span>$</pre></div></div>

<p><strong>Currency &#8211; British Pounds with commas for multiple&#8217;s of 1000 and a period for the decimal:</strong><br />
£12,000.23</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^\u00A3?<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#41;</span>$</pre></div></div>

<p><strong>Currency &#8211; Euros with periods for multiple&#8217;s of 1000 and a comma for the decimal:</strong><br />
€12.000,23</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^\u20AC?<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#41;</span>$</pre></div></div>

<p><strong>Currency &#8211; Euros, French style, with spaces for multiple&#8217;s of 1000 and a comma for the decimal:</strong><br />
€12 000.23</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^\u20AC?<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span>\s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #339933;">|</span><span style="color: #009900;">&#40;</span>\<span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#41;</span>$</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/tips/common-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon Kindle Reduced Price to $299</title>
		<link>http://www.phpreferencebook.com/misc/amazon-kindle-reduced-price/</link>
		<comments>http://www.phpreferencebook.com/misc/amazon-kindle-reduced-price/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 13:44:19 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[kindle]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=273</guid>
		<description><![CDATA[Amazon has dropped the price on their original 6&#8243; Kindle e-book reader to $299. Now you can carry around your reference book and more for the same weight and dimensions as a copy of just the PHP reference book! Sleek and lightweight, Kindle is as thin as a typical magazine and holds over 1,500 books. [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon has dropped the price on their original 6&#8243; <a href="http://www.amazon.com/gp/product/B00154JDAI?tag=phpreferencebook-20">Kindle e-book reader</a> to <strong>$299</strong>. Now you can carry around your reference book and more for the same weight and dimensions as a copy of just the PHP reference book! Sleek and lightweight, <a href="http://www.amazon.com/gp/product/B00154JDAI?tag=phpreferencebook-20">Kindle</a> is as thin as a typical magazine and holds over 1,500 books.  An advanced display reads like real paper and boasts 16 shades of gray for clear text and crisp images. The current generation has improved page refresh: faster page flips as the e-ink changes the entire page. Even better, small changes to the page don&#8217;t require a full refresh (the black-white flash) of the entire page!</p>
<p>A kindle version of PHP Reference: Beginner to Intermediate PHP5 is available for <a href="http://www.amazon.com/gp/product/B001B3HULC?ie=UTF8&#038;tag=phpreferencebook-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=B001B3HULC">$3.99 through Amazon</a>, the lowest priced general PHP book available!</p>
<p>If you are more interested in the larger format <a href="http://www.amazon.com/gp/product/B0015TCML0?ie=UTF8&#038;tag=phpreferencebook-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=B0015TCML0">Kindle DX</a>  9.7&#8243; model, it includes much better support for PDF files. You can then load the <a href="http://www.phpreferencebook.com/pdf/">free PDF version</a> of the PHP Book onto your DX at no additional cost!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/misc/amazon-kindle-reduced-price/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>8000+ downloads of PHP Book PDF!</title>
		<link>http://www.phpreferencebook.com/author-notes/8000-downloads-php-book-pdf/</link>
		<comments>http://www.phpreferencebook.com/author-notes/8000-downloads-php-book-pdf/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 06:06:55 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Author Notes]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[revenue]]></category>
		<category><![CDATA[self-publishing]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=261</guid>
		<description><![CDATA[Since tracking, over 8000 copies of this PHP book&#8217;s free PDF have been downloaded through lulu.com as well as directly through this book blog! This doesn&#8217;t include the downloads through other websites who are also hosting the PDF file completely legally. To date, there have also been 97 revenue generating print copies of the paperback [...]]]></description>
			<content:encoded><![CDATA[<p>Since tracking, over 8000 copies of this PHP book&#8217;s free PDF have been downloaded through <a href="http://www.phpreferencebook.com/ref">lulu.com</a> as well as <a href="http://www.phpreferencebook.com/pdf/">directly</a> through this book blog! This doesn&#8217;t include the downloads through other websites who are also hosting the PDF file completely legally.</p>
<p>To date, there have also been 97 revenue generating print copies of the paperback sold and 60 digital Kindle editions sold. The majority of sales are through Amazon.com, generating a lot less income per book than copies sold through lulu.com. </p>
<ul>
<li><strong>Total Revenue (all sources):</strong> $501.18</li>
<li><strong>Costs to create the book:</strong> ~$600<br />
(computer monitor, ISBN, review copies, office space rent, etc.)</li>
<li><strong>Hours spent writing: 175</strong></li>
</ul>
<p>In other words, with costs included, I&#8217;ve <strong>lost ~$100</strong> creating the book. If that was <strong>not</strong> factored in, the hourly wage for creating the book so far would be $2.86/hour <em>(in reality it is $0.00)</em>. </p>
<p>With over 8,000 downloads which are and will always remain free in PDF form, a donation of $1 for each download would have changed it to ~$33/hour. Would you consider <a href="http://www.phpreferencebook.com/purchase/">purchasing</a> a paperback PHP book copy today or <a href="http://www.dreamhost.com/donate.cgi?id=11264">donating to my hosting costs</a> when <a href="http://www.phpreferencebook.com/pdf/">downloading a free PDF</a> of the PHP reference book? Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/author-notes/8000-downloads-php-book-pdf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 3.417 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-31 22:11:56 -->
<!-- Compression = gzip -->