<?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>Down Lifes Road... &#187; refactoring</title>
	<atom:link href="http://www.downlifesroad.com/tag/refactoring/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.downlifesroad.com</link>
	<description></description>
	<lastBuildDate>Wed, 04 Aug 2010 22:37:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Old code.</title>
		<link>http://www.downlifesroad.com/2008/09/18/old-code/</link>
		<comments>http://www.downlifesroad.com/2008/09/18/old-code/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 22:35:59 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=12</guid>
		<description><![CDATA[I love coming across old code *cough* garbage *cough* The purpose of this was to take a title, and create something url safe and in the fashion a client was wanting. The first function was old code, so don&#8217;t blame me. function cleanUrl($url) { $find = array('/--/', '/ - /','/ /', '/!/', '/"/', "/'/", '/--/'); [...]]]></description>
			<content:encoded><![CDATA[<p>I love coming across old code *cough* garbage *cough*</p>
<p>The purpose of this was to take a title, and create something url safe and in the fashion a client was wanting. The first function was old code, so don&#8217;t blame me.</p>
<pre lang="php">
function cleanUrl($url)
{
  $find =        array('/--/', '/ - /','/ /', '/!/', '/"/', "/'/", '/--/');
  $replace =    array('-', '-', '-', '', '', '', '-');

  $result = strtr($url, "`~@#$%^&#038;*()_=+|[]{};:,./<>?", "---------------------------");

  return strtolower(preg_replace($find, $replace, strip_tags(stripslashes(trim($result)))));
}
</pre>
<p>Isn&#8217;t it horrible?</p>
<p>I rewrote the function to&#8230;</p>
<pre lang="php">
function cleanUrl($url)
{
  $url = strtolower($url);

  $url = preg_replace("/[^a-z0-9\s+]/", '', $url);
  $url = preg_replace("/[\s]{1,}/", '-', $url);

  return $url;
}
</pre>
<p>That makes me happier.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2008/09/18/old-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
