<?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>overfrown &#187; PHP</title>
	<atom:link href="http://www.overfrown.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.overfrown.com</link>
	<description></description>
	<lastBuildDate>Sat, 18 Sep 2010 15:38:40 +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>Title &#8220;keywordize&#8221; function</title>
		<link>http://www.overfrown.com/2009/09/title-keywordize-function/</link>
		<comments>http://www.overfrown.com/2009/09/title-keywordize-function/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 03:33:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.overfrown.com/?p=3</guid>
		<description><![CDATA[This function is used to fetch a valid keyword string for use in a URL. This function comes in handy when you want to structure your URLs to contain keywords found in the page&#8217;s title, for example. Any non alphanumeric characters are stripped from the string, and spaces are replaced with dashes. Extra whitespace is [...]]]></description>
			<content:encoded><![CDATA[<p>This function is used to fetch a valid keyword string for use in a URL. This function comes in handy when you want to structure your URLs to contain keywords found in the page&#8217;s title, for example.</p>
<p>Any non alphanumeric characters are stripped from the string, and spaces are replaced with dashes. Extra whitespace is accounted for.</p>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'This is the &quot;Best&quot; Function Ever!'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> keywordize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Output:</p>
<blockquote><p>this-is-the-best-function-ever</p></blockquote>
<p>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> keywordize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^[^a-z0-9]|[^a-z0-9]+$/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/ +|(\.{2,}[ ]?)+/s'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/[^a-z0-9_-]/s'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/(-{2,})/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/((^-)|(-$))/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can use the output of this function in your URLs like most CMS applications do to make your URLs search engine friendly.</p>
<p>You can add weight to the keywords within you page by containing them within the page&#8217;s URL.</p>
<p>I&#8217;ve written a short tutorial on <a href="http://www.overfrown.com/2009/10/how-to-use-modrewrite-in-htaccess-to-include-search-engine-friendly-keywords-in-urls/">adding search engine friendly keywords to a URL with ModRewrite</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.overfrown.com/2009/09/title-keywordize-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

