<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Refreshingly Blue</title>
	
	<link>http://www.refreshinglyblue.com</link>
	<description>Notes by Lee Blue</description>
	<lastBuildDate>Thu, 25 Jun 2009 02:58:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/RefreshinglyBlue" type="application/rss+xml" /><item>
		<title>Great Use For Javascript Closures</title>
		<link>http://www.refreshinglyblue.com/2009/06/24/great-use-for-javascript-closures/</link>
		<comments>http://www.refreshinglyblue.com/2009/06/24/great-use-for-javascript-closures/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 01:28:17 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Everyday Tips]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=138</guid>
		<description><![CDATA[setTimeout() with a paramter
If you need to use the setTimeout() function to call a javascript function that accepts a parameter you might be tempted to use syntax like
setTimeout('functionName()', 1500, param1, param2, etc); 
And you would probably have success until you went to test your site in Internet Explorer. Firefox seems to be able to handle [...]]]></description>
			<content:encoded><![CDATA[<h1>setTimeout() with a paramter</h1>
<p>If you need to use the setTimeout() function to call a javascript function that accepts a parameter you might be tempted to use syntax like</p>
<pre name="code" class="javascript">setTimeout('functionName()', 1500, param1, param2, etc); </pre>
<p>And you would probably have success until you went to test your site in Internet Explorer. Firefox seems to be able to handle the extra parameters on the end of the setTimeout() call but IE simply sends undefined variables to the function you are calling and your script dies.</p>
<p>Here is the solution &#8211; use closures! They are a little tricky to understand if you are new to the idea but, in a nutshell, you are assign a function to a variable. Normally you assign numbers, or strings to variables &#8211; well you can assign functions to variables too. Here&#8217;s how:</p>
<pre name="code" class="javascript">setTimeout(function() { delayedFunctionName(param1); }, 1500); </pre>
<p>This causes the function delayedFunctionName(p1) to be called with a 1.5 second delay AND the p1 parameter actually gets a value!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2009/06/24/great-use-for-javascript-closures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Then != Than</title>
		<link>http://www.refreshinglyblue.com/2009/04/22/then-than/</link>
		<comments>http://www.refreshinglyblue.com/2009/04/22/then-than/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 15:44:23 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Everyday Tips]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=133</guid>
		<description><![CDATA[I can&#8217;t believe how many people seem to not know the difference between then and than. They are not the same word at all. For some reason people tend to forget about &#8220;than&#8221; altogether and only use &#8220;then&#8221; and it is extremely annoying. So FOR THE LOVE OF ALL THINGS DECENT please learn the difference [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t believe how many people seem to not know the difference between then and than. They are not the same word at all. For some reason people tend to forget about &#8220;than&#8221; altogether and only use &#8220;then&#8221; and it is extremely annoying. So FOR THE LOVE OF ALL THINGS DECENT <strong>please learn the difference between then and than</strong>. Then means next and than means instead of. Here are a few examples.</p>
<h1>Proper Use of THEN</h1>
<p>First I will shower, THEN I will get dressed.</p>
<p>I saw him fall THEN he cried like a baby.</p>
<p>Open up the system folder THEN click the remote login check box.</p>
<h1>Proper Use of THAN</h1>
<p>I&#8217;d rather eat grapes THAN grass.</p>
<p>Men are generally taller THAN women are.</p>
<p>Fried food is less healthy THAN raw vegetables.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2009/04/22/then-than/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Share Files Between Linux and Mac</title>
		<link>http://www.refreshinglyblue.com/2009/04/21/share-files-between-linux-and-mac/</link>
		<comments>http://www.refreshinglyblue.com/2009/04/21/share-files-between-linux-and-mac/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 02:32:01 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Everyday Tips]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=131</guid>
		<description><![CDATA[It is EXTREMELY easy to happily share files between your linux system and your mac. I use both Ubuntu and Mac OS X. Simply login into you mac desktop, open up your system settings and turn on Remote Login. This enables incoming SSH connections to your mac. If you want to connect while you are [...]]]></description>
			<content:encoded><![CDATA[<p>It is EXTREMELY easy to happily share files between your linux system and your mac. I use both Ubuntu and Mac OS X. Simply login into you mac desktop, open up your system settings and turn on Remote Login. This enables incoming SSH connections to your mac. If you want to connect while you are away from home, you can set up some sort of dynamic IP service like DynDNS.org. Open up port 22 on your home firewall or router and you can connect to your home mac from anywhere you go with an internet connection.</p>
<p>Once your mac has SSH enabled, log into your Ubuntu machine and click Places &#8211;> Connect To Server. Choose SSH as your Service Type. Enter in the IP address of your mac or whatever name you may have assigned to it in your /etc/hosts file or whatever. Use the username and password you use to log into mac and there you go. You can browse files on your mac with your Ubuntu machine in Nautilus.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2009/04/21/share-files-between-linux-and-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Uploaded Images – How To Change Absolute URL</title>
		<link>http://www.refreshinglyblue.com/2009/03/29/wordpress-uploaded-images-how-to-change-absolute-url/</link>
		<comments>http://www.refreshinglyblue.com/2009/03/29/wordpress-uploaded-images-how-to-change-absolute-url/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 00:30:50 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=128</guid>
		<description><![CDATA[When working with WordPress, you may develop a site on a development server with a different domain than the live server where you intend to deploy the site. When you upload images in a post or a page, WordPress assigns an absolute link as the source of the image. Here is a quick SQL query [...]]]></description>
			<content:encoded><![CDATA[<p>When working with WordPress, you may develop a site on a development server with a different domain than the live server where you intend to deploy the site. When you upload images in a post or a page, WordPress assigns an absolute link as the source of the image. Here is a quick SQL query to run  after you migrate your site to the live server so that the absolute URL is updated to reflect the changed domain name.</p>
<pre name="code" class="sql">
UPDATE wp_posts set post_content=REPLACE(post_content, 'www.devServer.com/', 'www.liveServer.com/');
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2009/03/29/wordpress-uploaded-images-how-to-change-absolute-url/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>UPDATED: PHP Snake Case To Camel Case</title>
		<link>http://www.refreshinglyblue.com/2009/03/20/php-snake-case-to-camel-case/</link>
		<comments>http://www.refreshinglyblue.com/2009/03/20/php-snake-case-to-camel-case/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 16:55:04 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=97</guid>
		<description><![CDATA[For anyone interested in converting snake_case_strings into CamelCaseStrings, here&#8217;s a quick php snippet to do it:

/**
* Take a string_like_this and return a StringLikeThis
*
* @param string
* @return string
*/
function _snakeToCamel($val) {
return str_replace(' ', '', ucwords(str_replace('_', ' ', $val)));
}

Or if you prefer the inline thing&#8230;

$val = 'snake_case_string';
$val = str_replace(' ', '', ucwords(str_replace('_', ' ', $val)));
echo $val; // Output: [...]]]></description>
			<content:encoded><![CDATA[<p>For anyone interested in converting snake_case_strings into CamelCaseStrings, here&#8217;s a quick php snippet to do it:</p>
<pre name="code" class="php">
/**
* Take a string_like_this and return a StringLikeThis
*
* @param string
* @return string
*/
function _snakeToCamel($val) {
return str_replace(' ', '', ucwords(str_replace('_', ' ', $val)));
}
</pre>
<p>Or if you prefer the inline thing&#8230;</p>
<pre name="code" class="php">
$val = 'snake_case_string';
$val = str_replace(' ', '', ucwords(str_replace('_', ' ', $val)));
echo $val; // Output: SnakeCaseString
</pre>
<h1>Update: Back To CamelCaseString</h1>
<p>The popularity of this post has prompted the natural question on how to go from snake_case_string to the camel case version &#8211; SnakeCaseString. This gives me the opportunity to make use of a little known feature of php, the create_function function which allows you to make inline, anonymous, functions and use them as parameters. Take a look at this function to see it in use.</p>
<pre name="code" class="php">
function _camelToSnake($val) {
return preg_replace_callback('/[A-Z]/',
create_function('$match', 'return "_" . strtolower($match[0]);'),
$val);
}
</pre>
<p><strong>ANOTHER UPDATE:</strong> Some people want to get a stringLikeThis rather than a StringLikeThis &#8211; keeping the first letter lowercase. This is actually a little trickier to accomplish because there is no lcfirst() function like there is a ucfirst() function <em>[NOTE: lcfirst() is coming in PHP 5.3]</em>. So here is an updated function that returns your camelCaseValue starting with a lowercase letter.</p>
<pre name="code" class="php">
function _snakeToCamel($val) {
$val = str_replace(' ', '', ucwords(str_replace('_', ' ', $val)));
$val = strtolower(substr($val,0,1)).substr($val,1);
return $val;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2009/03/20/php-snake-case-to-camel-case/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Vim: How To Fold Functions</title>
		<link>http://www.refreshinglyblue.com/2009/03/20/vim-how-to-fold-functions/</link>
		<comments>http://www.refreshinglyblue.com/2009/03/20/vim-how-to-fold-functions/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 16:42:54 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Everyday Tips]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Vim]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=111</guid>
		<description><![CDATA[
The is really a tip on how to fold any code block including functions. Navigate your cursor somewhere inside of the code block you want to fold, make sure you are in command/normal mode (press escape if you need to) then type zfa}
To save your folds between vim sessions you need to issue the command [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.digitalunderware.com/briefcase/vi-gang-sign-100.jpg" alt="Vi Gang Sign" align='right' style='padding: 10px;' /></p>
<p>The is really a tip on how to fold <b>any code block including functions</b>. Navigate your cursor somewhere inside of the code block you want to fold, make sure you are in command/normal mode (press escape if you need to) then type zfa}</p>
<p>To save your folds between vim sessions you need to issue the command :mkview otherwise when you close vim your folds will be lost (your folds, not your code). To make life easier on you, you can have your folds automatically saved for you by adding this to your .vimrc file</p>
<p>au BufWinLeave * mkview<br />
 au BufWinEnter * silent loadview</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2009/03/20/vim-how-to-fold-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursive searching in vim with grep – vimgrep</title>
		<link>http://www.refreshinglyblue.com/2009/02/17/recursive-searching-in-vim-with-grep-vimgrep/</link>
		<comments>http://www.refreshinglyblue.com/2009/02/17/recursive-searching-in-vim-with-grep-vimgrep/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 22:50:42 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Everyday Tips]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Vim]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=102</guid>
		<description><![CDATA[
One of the smartest people I&#8217;ve ever digitally met, Ryan Paul, taught me this awesome tip for doing a project wide search in vim. I needed to look for all occurrences of the patter _Models_ in a PHP project I was working on and you can do it right inside of vim &#8211; the best [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.digitalunderware.com/briefcase/vi-gang-sign-100.jpg" alt="Vi Gang Sign" align='right' style='padding: 10px;' /></p>
<p>One of the smartest people I&#8217;ve ever digitally met, <a href="http://arstechnica.com/authors/ryan-paul/">Ryan Paul</a>, taught me this awesome tip for doing a project wide search in vim. I needed to look for all occurrences of the patter _Models_ in a PHP project I was working on and you can do it right inside of vim &#8211; the best text editor ever invented.</p>
<ol>
<li>Open vim and make sure you are in the top level folder of your project by typing :pwd<enter></li>
<li>Then type :vimgrep <em>YourPattern</em> **/*.php</li>
<li>To open your search results in their own buffer type :copen</li>
</ol>
<p>The **/ recursively searches through all your directories for you pattern. <em>:copen</em> opens the search results in their own buffer. You can use the arrow keys to move up and down through the list and hit enter to have it open that result in the main buffer. You can also use <em>:cnext</em> and <em>:cprev</em> to move to the next and previous items in the list. Perhaps you might bind those to keyboard shortcuts so you can move through the search results quickly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2009/02/17/recursive-searching-in-vim-with-grep-vimgrep/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Delete URL Auto-fill In Safari – One At A Time</title>
		<link>http://www.refreshinglyblue.com/2008/12/12/how-to-delete-url-auto-fill-in-safari-one-at-a-time/</link>
		<comments>http://www.refreshinglyblue.com/2008/12/12/how-to-delete-url-auto-fill-in-safari-one-at-a-time/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 14:50:59 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Everyday Tips]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=93</guid>
		<description><![CDATA[I like using Safari and I&#8217;m a web developer. Sometimes I&#8217;ll be developing a website and then decide to rename a page. The problem is Safari will cache the old pages&#8217; URL and then auto-fill the old URL as I&#8217;m typing. Then I hit enter and shucks, I&#8217;m getting a File Not Found error. In [...]]]></description>
			<content:encoded><![CDATA[<p>I like using Safari and I&#8217;m a web developer. Sometimes I&#8217;ll be developing a website and then decide to rename a page. The problem is Safari will cache the old pages&#8217; URL and then auto-fill the old URL as I&#8217;m typing. Then I hit enter and shucks, I&#8217;m getting a File Not Found error. In FireFox you can just press Shift-Delete to get rid of the outdated URL. In Safari, to delete one, several, or even all of your cached urls used by the auto-fill feature, just delete the offending URLs from your history.</p>
<p>To do this you can go to Bookmarks &ndash;&gt; Show All Bookmarks. Then in the upper right corner of your window you can search for the URL you want to delete. I&#8217;m frequently typing the domain of our development server so I can delete all of the development URLs they may be outdated. Once you see the URLs you want to delete, highlight them and press Delete. This is a little more cumbersome than Firefox&#8217;s Shift-Delete but at least it can be done.</p>
<p><strong>Note:</strong> Both History and Bookmarks are used for the auto-fill feature. So even if you delete all of your history, the URLs from your Bookmarks will still be used for auto-fill. Of course, if you have bookmarked a page that is no longer available you probably want to delete that too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2008/12/12/how-to-delete-url-auto-fill-in-safari-one-at-a-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multiple Gmail Signatures</title>
		<link>http://www.refreshinglyblue.com/2008/12/10/multiple-gmail-signatures/</link>
		<comments>http://www.refreshinglyblue.com/2008/12/10/multiple-gmail-signatures/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 03:29:40 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Everyday Tips]]></category>
		<category><![CDATA[Mac OSX]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=87</guid>
		<description><![CDATA[I Want Mulitple Gmail Signatures
I love using Gmail and I have several different email address for the various companies I work for. Gmail only lets me have one signature which is a bit of a problem because, depending on which from address I am using, I use different email signatures. There are a couple of [...]]]></description>
			<content:encoded><![CDATA[<h1>I Want Mulitple Gmail Signatures</h1>
<p>I love using Gmail and I have several different email address for the various companies I work for. Gmail only lets me have one signature which is a bit of a problem because, depending on which <em>from</em> address I am using, I use different email signatures. There are a couple of Firefox add-ons that help with the problem but sometime I enjoy using other browsers like Safari. I have finally found the solution using QuickSilver and it&#8217;s <em>Shelf</em> feature.</p>
<h1>QuickSilver And The Shelf</h1>
<p>I&#8217;ve know about the Shelf on QuickSilver for a while now. It&#8217;s like a persistent clipboard. You can save snippets of text and then use that text later &#8211; like copying things to the clipboard but it stays there forever. So this was a good solution for my multiple email signature problem except that it took quite a few key stokes to get the text off the shelf and into my email. I set up triggers to do this but QuickSilver&#8217;s trigger display doesn&#8217;t handle the multi-line signature trigger very well. The name of the trigger spans multiple lines and overlaps the names of my other triggers. I hate that so I avoided using that as a solution. Also, it&#8217;s hard to think of enough unique keyboard shortcuts of each one of my five different signatures that don&#8217;t interfere with other shortcuts. So I created a trigger that just opened the shelf. Once the shelf is open I right-click the signature I want, then select <em>paste</em> from the actions menu. This was a fair solution, but the right-clicking and then hunting for <em>paste</em> in the pop-up actions menu was still a bit cumbersome.</p>
<h1>Command Chains Can Be Stored On The Shelf</h1>
<p>What I didn&#8217;t realize until today, was that you can store more than just text on the shelf. You can store chains of actions. So now my workflow is really nice. I have a keyboard shortcut that pulls up the Shelf then I just double-click on the signature I want and Blamo! my signature is in my email. Since this is a QuickSilver thing, I can use the signature for Mail.app, or Gmail and I can use any browser I want. It&#8217;s very nice. The one last tweak I wish I could figure out is how to get rich text in my signature because it seem that only plain text can be stored in QuickSilver&#8217;s shelf.</p>
<h1>How To Store Command Chains On The Shelf</h1>
<p>The huge realization I had today was that you can type Control-Enter rather than just Enter to make a chain of actions in QuickSilver. So I create the text (type . in the subject panel) for my email signature. Then tab to the action window and type <em>paste</em> the type Control-Enter and type <em>Put on Shelf</em> then click Execute.  Now you can open your shelf, double-click your signature and it is pasted into whatever text area you were just in.</p>
<p>If anybody knows how to get rich text into the signature I would LOVE to know. I know that you can copy from Pages or Word or whatever and the bold, italics, links, etc come with you when you paste into Gmail. So I&#8217;ve thought about writing an AppleScript to open up a Pages document with my signature, copy the content to the clipboard, quitting Pages, then paste the clipboard. But the launching and quitting of pages takes too long and is more trouble than it&#8217;s worth.</p>
<h1>Video Tutorial</h1>
<p>Here is a quick video tutorial showing how to set all this up.</p>
<p><embed src="http://blip.tv/play/Ad_0PwA" type="application/x-shockwave-flash" width="479" height="272" allowscriptaccess="always" allowfullscreen="true"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2008/12/10/multiple-gmail-signatures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursively Delete A Non-Empty Directory With PHP5</title>
		<link>http://www.refreshinglyblue.com/2008/11/26/recursively-delete-a-non-empty-directory-with-php5/</link>
		<comments>http://www.refreshinglyblue.com/2008/11/26/recursively-delete-a-non-empty-directory-with-php5/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 17:41:35 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.refreshinglyblue.com/?p=80</guid>
		<description><![CDATA[There are bunches of examples on how to delete non-empty directories in PHP but none of the examples that I&#8217;ve seen take advantage of PHP5&#8217;s RecursiveDirectoryIterator which makes this an almost trivial task. If you haven&#8217;t already, please check out the SPL Standard PHP Library Classes. I keep a class of static utility functions and [...]]]></description>
			<content:encoded><![CDATA[<p>There are bunches of examples on how to delete non-empty directories in PHP but none of the examples that I&#8217;ve seen take advantage of PHP5&#8217;s RecursiveDirectoryIterator which makes this an almost trivial task. If you haven&#8217;t already, please check out the <a href='http://www.php.net/~helly/php/ext/spl/'>SPL Standard PHP Library Classes</a>. I keep a class of static utility functions and here is my function to delete non-empty directories recursively. </p>
<pre name="code" class="php">
public static function deleteDir($dir) {
    $iterator = new RecursiveDirectoryIterator($dir);
    foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
      if ($file->isDir()) {
         rmdir($file->getPathname());
      } else {
         unlink($file->getPathname());
      }
    }
    rmdir($dir);
}
</pre>
<p>Please note the RecursiveIteratorIterator::CHILD_FIRST parameter. Without that the listing will not be in the correct order. As you iterate along you will end up trying to delete directories before they are empty. This CHILD_FIRST parameter was added with PHP 5.1 so make sure you have at least that  version installed before using this technique.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refreshinglyblue.com/2008/11/26/recursively-delete-a-non-empty-directory-with-php5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 0.239 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-07-11 22:22:08 -->
