<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1.3" -->
<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/"
	>

<channel>
	<title>Code a Day</title>
	<link>http://code-a-day.com</link>
	<description>Better code, one day at a time</description>
	<pubDate>Mon, 10 Dec 2007 19:20:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.3</generator>
	<language>en</language>
			<item>
		<title>Javascript Framework Speed Tests</title>
		<link>http://code-a-day.com/2007/12/10/javascript-framework-speed-tests/</link>
		<comments>http://code-a-day.com/2007/12/10/javascript-framework-speed-tests/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 19:19:40 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[Language]]></category>

		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/12/10/javascript-framework-speed-tests/</guid>
		<description><![CDATA[A coworker just pointed out a cool JS speed test to me today. The folks over at MooTools have a handy dandy speed test to compare the top three JS framework libraries to each other. As you can see, Prototype seems to be optimized for Firefox, JQuery for IE and MooTools appears to be a [...]]]></description>
			<content:encoded><![CDATA[<p>A coworker just pointed out a cool JS speed test to me today. The folks over at MooTools have a handy dandy speed test to compare the top three JS framework libraries to each other. As you can see, Prototype seems to be optimized for Firefox, JQuery for IE and MooTools appears to be a nice middle ground for comparable performance cross browser.</p>
<p><a href="http://mootools.net/slickspeed/">http://mootools.net/slickspeed/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/12/10/javascript-framework-speed-tests/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Page mySQL query results through your favorite pager</title>
		<link>http://code-a-day.com/2007/10/04/page-mysql-query-results-through-your-favorite-pager/</link>
		<comments>http://code-a-day.com/2007/10/04/page-mysql-query-results-through-your-favorite-pager/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 17:49:50 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[General Tips]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/10/04/page-mysql-query-results-through-your-favorite-pager/</guid>
		<description><![CDATA[Every time I connect to a mysql server, I see the &#8220;Type 'help;' or '\h' for help. Type '\c' to clear the buffer.&#8221; notice but just ignore it. This morning I decided to &#8216;\h&#8217; just to see what the in-line help was and found a score of useful commands I had never known about before, [...]]]></description>
			<content:encoded><![CDATA[<p>Every time I connect to a mysql server, I see the &#8220;<code>Type 'help;' or '\h' for help. Type '\c' to clear the buffer.</code>&#8221; notice but just ignore it. This morning I decided to &#8216;\h&#8217; just to see what the in-line help was and found a score of useful commands I had never known about before, possibly the most useful one being &#8216;\P&#8217;.</p>
<blockquote><p>pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.</p></blockquote>
<p>if I had a nickel for every minute I spent changing the scrollback of my terminal and then scrolling back for pages and pages to investigate query results I&#8217;d be a thousandaire. A simple &#8216;<code>\P less;</code>&#8216; now makes my life a little easier. Of course, if you don&#8217;t think <code>less</code> is <code>more</code>, you can &#8216;<code>\P more;</code>&#8216; instead.</p>
<p>For the curious, here&#8217;s the totality of the &#8216;\h&#8217; output:</p>
<blockquote><p>
List of all MySQL commands:<br />
Note that all text commands must be first on line and end with &#8216;;&#8217;<br />
?         (\?) Synonym for `help&#8217;.<br />
clear     (\c) Clear command.<br />
connect   (\r) Reconnect to the server. Optional arguments are db and host.<br />
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.<br />
edit      (\e) Edit command with $EDITOR.<br />
ego       (\G) Send command to mysql server, display result vertically.<br />
exit      (\q) Exit mysql. Same as quit.<br />
go        (\g) Send command to mysql server.<br />
help      (\h) Display this help.<br />
nopager   (\n) Disable pager, print to stdout.<br />
notee     (\t) Don&#8217;t write into outfile.<br />
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.<br />
print     (\p) Print current command.<br />
prompt    (\R) Change your mysql prompt.<br />
quit      (\q) Quit mysql.<br />
rehash    (\#) Rebuild completion hash.<br />
source    (\.) Execute an SQL script file. Takes a file name as an argument.<br />
status    (\s) Get status information from the server.<br />
system    (\!) Execute a system shell command.<br />
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.<br />
use       (\u) Use another database. Takes database name as argument.<br />
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.<br />
warnings  (\W) Show warnings after every statement.<br />
nowarning (\w) Don&#8217;t show warnings after every statement.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/10/04/page-mysql-query-results-through-your-favorite-pager/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Terry Chay: Why PHP triumphs over Ruby</title>
		<link>http://code-a-day.com/2007/09/24/terry-chay-why-php-triumphs-over-ruby/</link>
		<comments>http://code-a-day.com/2007/09/24/terry-chay-why-php-triumphs-over-ruby/#comments</comments>
		<pubDate>Mon, 24 Sep 2007 16:49:53 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/09/24/terry-chay-why-php-triumphs-over-ruby/</guid>
		<description><![CDATA[Terry Chay writes another hilarious post about PHP vs. Ruby
    “I’m really low on my scatological count here…I’m sorry I didn’t crack enough jokes or use enough [cuss words], but I’m sure people will forgive me. They can just attend one of my talks and get their cuss quota for the year. [...]]]></description>
			<content:encoded><![CDATA[<p>Terry Chay writes another hilarious post about PHP vs. Ruby</p>
<blockquote><p>    “I’m really low on my scatological count here…I’m sorry I didn’t crack enough jokes or use enough [cuss words], but I’m sure people will forgive me. They can just attend one of my talks and get their cuss quota for the year. And if not, coding these web apps themselves involves a lot of swearing—a lot of blood, sweat and swear.”<br />
    —me on Pro PHP Podcast</p>
<p>I’m not posting my talk yet because I have to give it again at ZendCon. So here is a bit of a teaser.</p>
<p><a href="http://terrychay.com/blog/article/php-ruby-evil-good.shtml">[Do not hit the jump if you are easily offended. I really mean it!]</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/09/24/terry-chay-why-php-triumphs-over-ruby/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Being nice With Long Processes</title>
		<link>http://code-a-day.com/2007/09/15/being-nice-with-long-processes/</link>
		<comments>http://code-a-day.com/2007/09/15/being-nice-with-long-processes/#comments</comments>
		<pubDate>Sun, 16 Sep 2007 02:43:33 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[General Tips]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/09/15/being-nice-with-long-processes/</guid>
		<description><![CDATA[Every once and a while, I find that I need to compile code on a machine where many other more important things are running. In my case, I generally find myself recompiling PHP on a machine that also runs my very active forum website [http://forums.reebosak.net] in addition to many other websites, including this one. Running [...]]]></description>
			<content:encoded><![CDATA[<p>Every once and a while, I find that I need to compile code on a machine where many other more important things are running. In my case, I generally find myself recompiling PHP on a machine that also runs my very active forum website [http://forums.reebosak.net] in addition to many other websites, including this one. Running a long build is not exactly the nicest thing to do to users who are trying to go about their normal browsing, where a long build would cause really long page loads since the processor is so busy. The way to deal with this is by being <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?nice"><code>nice</code></a> (and <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?renice"><code>renice</code></a>).</p>
<p>from the UNIX man page:</p>
<blockquote><pre>
NAME

       nice - run a program with modified scheduling priority

DESCRIPTION

       Run  COMMAND  with an adjusted niceness, which affects process schedul-
       ing.  With no COMMAND, print the current  niceness.   Nicenesses  range
       from -20 (most favorable scheduling) to 19 (least favorable).
</pre>
</blockquote>
<p>To set a processes niceness run it with the nice command:</p>
<p><div class="codeblock"><code>[brien@toothbrush ~]$ nice -n 5 make // run make with +5 niceness (lower priority)<br />[brien@toothbrush ~]$ ps aux |grep make<br />brien&nbsp; &nbsp; &nbsp; 4560&nbsp; 0.0&nbsp; 0.1&nbsp; 5040 1180 pts/1&nbsp; &nbsp; SN+&nbsp; 18:36&nbsp;  0:00 make<br />[brien@toothbrush ~]$ sudo renice -3 4560 // change the niceness of the process to -3 (higher priority)<br /></code></div></p>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/09/15/being-nice-with-long-processes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Auto Converting PHP Objects to Strings using the __toString() &#8216;Magic Method&#8217;</title>
		<link>http://code-a-day.com/2007/09/11/auto-converting-php-objects-to-strings-using-the-__tostring-magic-method/</link>
		<comments>http://code-a-day.com/2007/09/11/auto-converting-php-objects-to-strings-using-the-__tostring-magic-method/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 21:40:04 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/09/11/auto-converting-php-objects-to-strings-using-the-__tostring-magic-method/</guid>
		<description><![CDATA[Ever wished there was a way to echo or print a PHP Object as if it were just a string and have it print something more usefull than Object id #1? In PHP5+ there is a Magic Method __toString() that will allow you to specify how you want your Object to react when converted to [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wished there was a way to <code>echo</code> or <code>print</code> a PHP Object as if it were just a string and have it print something more usefull than <code>Object id #1</code>? In PHP5+ there is a <a href="http://www.php.net/manual/en/language.oop5.magic.php">Magic Method</a> <code>__toString()</code> that will allow you to specify how you want your Object to react when converted to a string.</p>
<p><div class="codeblock"><code><span class="synSpecial">&lt;?php</span><br /><span class="synType">class</span> Person<span class="synSpecial">{</span><br />&nbsp;  <span class="synType">private</span> <span class="synStatement">$</span><span class="synIdentifier">firstName</span><span class="synStatement">=</span>&quot;<span class="synConstant">Brien</span>&quot;;<br />&nbsp;  <span class="synType">private</span> <span class="synStatement">$</span><span class="synIdentifier">lastName</span><span class="synStatement">=</span>&quot;<span class="synConstant">Wankel</span>&quot;;<br />&nbsp;  <span class="synType">private</span> <span class="synStatement">$</span><span class="synIdentifier">age</span><span class="synStatement">=</span>&quot;<span class="synConstant">30</span>&quot;;<br />&nbsp;  <span class="synStatement">...</span><br />&nbsp;  <span class="synType">public</span> <span class="synPreProc">function</span> __toString<span class="synSpecial">(){</span><br />&nbsp; &nbsp; &nbsp; <span class="synStatement">return</span> &quot;<span class="synSpecial">{</span><span class="synStatement">$</span><span class="synIdentifier">this</span><span class="synType">-&gt;</span>firstName<span class="synSpecial">}</span><span class="synConstant"> </span><span class="synSpecial">{</span><span class="synStatement">$</span><span class="synIdentifier">this</span><span class="synType">-&gt;</span>lastName<span class="synSpecial">}</span>&quot;;<br />&nbsp;  <span class="synSpecial">}</span><br /><span class="synSpecial">}</span><br /><span class="synStatement">$</span><span class="synIdentifier">me</span> <span class="synStatement">=</span> <span class="synPreProc">new</span> Person<span class="synSpecial">()</span>;<br /><span class="synIdentifier">echo</span><span class="synSpecial">(</span>&quot;<span class="synConstant">My name is </span><span class="synSpecial">{</span><span class="synStatement">$</span><span class="synIdentifier">me</span><span class="synSpecial">}</span>&quot;<span class="synSpecial">)</span>; <span class="synComment">// prints: My name is Brien Wankel</span><br /><span class="synSpecial">?&gt;</span><br /></code></div></p>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/09/11/auto-converting-php-objects-to-strings-using-the-__tostring-magic-method/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Web Development With PLT Scheme</title>
		<link>http://code-a-day.com/2007/08/26/web-development-with-plt-scheme/</link>
		<comments>http://code-a-day.com/2007/08/26/web-development-with-plt-scheme/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 05:23:17 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[Language]]></category>

		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/08/26/web-development-with-plt-scheme/</guid>
		<description><![CDATA[I just ran across this article about using PLT Scheme to write web applications. It&#8217;s a great read and a good introduction to Sceme and how it can be used to write &#8220;real&#8221; programs, not just academic assignments.

From time to time people ask how to develop for the web with PLT Scheme on the PLT [...]]]></description>
			<content:encoded><![CDATA[<p>I just ran across this article about using PLT Scheme to write web applications. It&#8217;s a great read and a good introduction to Sceme and how it can be used to write &#8220;real&#8221; programs, not just academic assignments.</p>
<blockquote><p>
From time to time people ask how to develop for the web with PLT Scheme on the PLT mailing list. The quick answer is &#8220;Just as in any other language&#8221;, but that&#8217;s not how to get people hooked on Scheme. To write a decent web-application require knowledge of a range of subjects such as HTML, databases, servlets, and web-servers. For some reason there is a lack of tutorials on these subjects, so I have decided to make an attempt at writing, if not a complete tutorial, then an elaborate get-started example.
</p></blockquote>
<p>[<a href="http://scheme.dk/blog/2007/01/introduction-to-web-development-with.html">Read the whole article at http://scheme.dk</a>]<br />
[<a href="http://www.scheme.dk/blog/2007/01/introduction-to-web-development-with_29.html">part two: the view</a>]<br />
[<a href="http://www.scheme.dk/blog/2007/04/introduction-to-web-development-with.html">part three: an intermezzo</a>]<br />
[<a href="http://www.scheme.dk/blog/2007/08/introduction-to-web-development-with.html">part four: the control</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/08/26/web-development-with-plt-scheme/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Learn Python in 10 Minutes</title>
		<link>http://code-a-day.com/2007/07/12/learn-python-in-10-minutes/</link>
		<comments>http://code-a-day.com/2007/07/12/learn-python-in-10-minutes/#comments</comments>
		<pubDate>Thu, 12 Jul 2007 16:32:07 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[Language]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/07/12/learn-python-in-10-minutes/</guid>
		<description><![CDATA[From http://www.poromenos.org/:
So, you want to learn the Python programming language but can&#8217;t find a concise and yet full-featured tutorial. This tutorial will attempt to teach you Python in 10 minutes. It&#8217;s probably not so much a tutorial as it is a cross between a tutorial and a cheatsheet, so it will just show you some [...]]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://www.poromenos.org/">http://www.poromenos.org/</a>:</p>
<blockquote><p>So, you want to learn the Python programming language but can&#8217;t find a concise and yet full-featured tutorial. This tutorial will attempt to teach you Python in 10 minutes. It&#8217;s probably not so much a tutorial as it is a cross between a tutorial and a cheatsheet, so it will just show you some basic concepts to start you off. Obviously, if you want to really learn a language you need to program in it for a while. I will assume that you are already familiar with programming and will, therefore, skip most of the non-language-specific stuff. The important keywords will be highlighted so you can easily spot them. Also, pay attention because, due to the terseness of this tutorial, some things will be introduced directly in code and only briefly commented on.</p></blockquote>
<p><a href="http://www.poromenos.org/tutorials/python">Go to the article >></a></p>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/07/12/learn-python-in-10-minutes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The One Line Cross-Browser Ajax Request Object</title>
		<link>http://code-a-day.com/2007/05/30/the-one-line-cross-browser-ajax-request-object/</link>
		<comments>http://code-a-day.com/2007/05/30/the-one-line-cross-browser-ajax-request-object/#comments</comments>
		<pubDate>Thu, 31 May 2007 04:37:42 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/05/30/the-one-line-cross-browser-ajax-request-object/</guid>
		<description><![CDATA[The simple task of getting a working XMLHTTPRequest object can quickly turn into a mess of if/then browser checking. With the help of one of my favorite operators, the ternary operator, this becomes a simple one-liner:
&#160; reqObj = window.XMLHttpRequest&#160; &#160; &#160;  ? new XMLHttpRequest() :&#160; &#160; &#160; &#160;  new ActiveXObject(&#34;Microsoft.XMLHTTP&#34;);
There you go, it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>The simple task of getting a working XMLHTTPRequest object can quickly turn into a mess of if/then browser checking. With the help of one of my favorite operators, <a href="http://en.wikipedia.org/wiki/Ternary_operation">the ternary operator</a>, this becomes a simple one-liner:</p>
<p><div class="codeblock"><code>&nbsp; reqObj = window.XMLHttpRequest<br />&nbsp; &nbsp; &nbsp;  ? <span class="synStatement">new</span> XMLHttpRequest() :<br />&nbsp; &nbsp; &nbsp; &nbsp;  <span class="synStatement">new</span> ActiveXObject(<span class="synConstant">&quot;Microsoft.XMLHTTP&quot;</span>);<br /></code></div></p>
<p>There you go, it&#8217;s that easy? Now, of course, this is an extremely stripped down browser check, with no error checking, so depending on your need, this may not be the best way to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/05/30/the-one-line-cross-browser-ajax-request-object/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Easily Syncing Remote Files in Komodo With Unison</title>
		<link>http://code-a-day.com/2007/05/04/easily-syncing-remote-files-in-komodo-with-unison/</link>
		<comments>http://code-a-day.com/2007/05/04/easily-syncing-remote-files-in-komodo-with-unison/#comments</comments>
		<pubDate>Fri, 04 May 2007 18:12:00 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[General Tips]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/05/04/easily-syncing-remote-files-in-komodo-with-unison/</guid>
		<description><![CDATA[in my day to day work, i have to edit code, then move the new code to a different server, then build a package for installation. until recently i was doing one of two things:
1) mounting an SMB/NFS share and editing the remote files directly
2) using rsync to copy files back and forth from my dev machine to my build machine

both methods "worked" but had their downsides.]]></description>
			<content:encoded><![CDATA[<p>In my day to day work, I edit code on one machine, then move the new code to a different machine to build packages for installation and testing. Until recently I was doing one of two things:<br />
1) Mounting an SMB/NFS share and editing the remote files directly<br />
2) Using rsync to copy files back and forth from my dev machine to my build machine</p>
<p>Both methods &#8220;worked&#8221; but had their downsides. With the remote SMB, I had to have network access if I wanted to work. Since I was also directly editing the source, I only had one copy and if I hadn&#8217;t checked in to CVS yet, and something went wrong, I could be screwed. I couldn&#8217;t work on anything if I was not connected to the corporate network here at work (ether physically, or via ssh tunnel).<br />
rsync worked alright, but the syncing is one way, so I had to do some weird double syncing to make sure all the changes were propagated. I had to be really careful with edits because if two files were changed in both locations, I would again screwed - no merging. One side of the changes would always be lost. The other downside to this was that if the system times on each machine were not *exactly* the same, rsync would sync files that were not edited, which changed the file&#8217;s timestamp, which then caused CVS to see them as edited. It was a mess.</p>
<p>A couple of weeks ago I found <a href="http://www.cis.upenn.edu/~bcpierce/unison/">Unison</a>:</p>
<blockquote><p>Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.</p></blockquote>
<p>With Unison, you simply set up the source and destination directories, which can be local or remote and then tell it to sync. There are optional ways of connecting to remote directories, I personally use ssh, which then uses an ssh tunnel I have set up in my ssh_config file. </p>
<p>This worked great, but I soon grew a little tired of editing files in Komodo, flipping to my Unison window, syncing, then flipping back to Komodo. Then it hit me, &#8220;why don&#8217;t i just set this sync up as a toolbox item?&#8221;. Unison has a command line interface, so after a quick read of the &#8216;-help&#8217; output, I created a toolbox item with <code>unison -batch -auto;</code> (read the &#8216;-help&#8217; to customize your sync with your own preferences), then set up a keyboard shortcut <code>CTRL+ALT+S</code> to trigger it. Now I can happily edit my code on my laptop and sync with a quick flick of the fingers.</p>
<p>NOTE: I have this set up in Linux, but since both Komodo and Unison are available for Windows, it should be trivial to accomplish the same in that environment</p>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/05/04/easily-syncing-remote-files-in-komodo-with-unison/feed/</wfw:commentRss>
		</item>
		<item>
		<title>An easier way to do simple matches with PHP</title>
		<link>http://code-a-day.com/2007/01/26/an-easier-way-to-do-simple-matches-with-php/</link>
		<comments>http://code-a-day.com/2007/01/26/an-easier-way-to-do-simple-matches-with-php/#comments</comments>
		<pubDate>Fri, 26 Jan 2007 21:45:27 +0000</pubDate>
		<dc:creator>brien</dc:creator>
		
		<category><![CDATA[Language]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://code-a-day.com/2007/01/26/an-easier-way-to-do-simple-matches-with-php/</guid>
		<description><![CDATA[Tired of trying to figure out that perfect Perl-style regular expression when all you need to do is a simple match? Well, toss away that ereg or preg_match call you&#8217;ve been working on for the last 20 minutes and use your new friend fnmatch(). fnmatch will let you match using POSIX shell command style patterns, [...]]]></description>
			<content:encoded><![CDATA[<p>Tired of trying to figure out that perfect Perl-style regular expression when all you need to do is a simple match? Well, toss away that <code>ereg</code> or <code>preg_match</code> call you&#8217;ve been working on for the last 20 minutes and use your new friend <code>fnmatch()</code>. <code>fnmatch</code> will let you match using POSIX shell command style patterns, which may be much much easier for a non regex guru to wrap their head around.</p>
<p><div class="codeblock"><code><span class="synSpecial">&lt;?php</span><br /><span class="synStatement">if</span> <span class="synSpecial">(</span><span class="synIdentifier">fnmatch</span><span class="synSpecial">(</span>&quot;<span class="synConstant">*gr[ae]y</span>&quot;, <span class="synStatement">$</span><span class="synIdentifier">color</span><span class="synSpecial">))</span> <span class="synSpecial">{</span><br />&nbsp; <span class="synIdentifier">echo</span> &quot;<span class="synConstant">some form of gray ...</span>&quot;;<br /><span class="synSpecial">}</span><br /><span class="synSpecial">?&gt;</span><br /></code></div></p>
<p>This function is only available on POSIX compliant systems, so all you Windows PHP users are out of luck.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://code-a-day.com/2007/01/26/an-easier-way-to-do-simple-matches-with-php/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
