<?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; php</title>
	<atom:link href="http://www.downlifesroad.com/tag/php/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>Zend Form Element Radio and Default value</title>
		<link>http://www.downlifesroad.com/2009/10/27/zend-form-element-radio-and-default-value/</link>
		<comments>http://www.downlifesroad.com/2009/10/27/zend-form-element-radio-and-default-value/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 17:44:59 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=21</guid>
		<description><![CDATA[I setup a Zend Form object and needed radio buttons, but also needed a default value. Took me a few minutes to find, but here&#8217;s an example of use. /** * Setting some values for our radio buttons. */ $options = array( '1' => 'Option 1', '2' => 'Option 2', '3' => 'Option 3' ); [...]]]></description>
			<content:encoded><![CDATA[<p>I setup a Zend Form object and needed radio buttons, but also needed a default value. Took me a few minutes to find, but here&#8217;s an example of use.</p>
<pre lang="php">
/**
 * Setting some values for our radio buttons.
 */
$options = array(
    '1' => 'Option 1',
    '2' => 'Option 2',
    '3' => 'Option 3'
);

/**
 * The array('value' => 2) below sets our default value.
 */
$radio = new Zend_Form_Element_Radio('elementName', array('value' => '2'));
$radio->addMultiOptions($options);
$this->addElement($radio);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2009/10/27/zend-form-element-radio-and-default-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
