<?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>nothing is clear &#187; string</title>
	<atom:link href="http://www.nothingisclear.net/?feed=rss2&#038;tag=string" rel="self" type="application/rss+xml" />
	<link>http://www.nothingisclear.net</link>
	<description>// a blog about web programming</description>
	<lastBuildDate>Tue, 30 Mar 2010 10:11:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Another slugify method for php</title>
		<link>http://www.nothingisclear.net/?p=47</link>
		<comments>http://www.nothingisclear.net/?p=47#comments</comments>
		<pubDate>Wed, 24 Mar 2010 14:21:13 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[slug]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.nothingisclear.net/?p=47</guid>
		<description><![CDATA[One more way to slugify texts in php, without the need of the iconv() function:

    public static function slugify($text) {
		$text = trim($text);
		$text = str_replace(&#34;.&#34;, &#34;&#34;, $text);
		$text = self::removeAccents($text);
		// replace non letter or digits by -
		$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
		// trim
		$text = trim($text, '-');
		// lowercase
		$text = strtolower($text);
		// remove unwanted characters
		$text = preg_replace('~[^-\w]+~', '', [...]]]></description>
			<content:encoded><![CDATA[<p>One more way to slugify texts in php, without the need of the iconv() function:</p>
<pre class="brush: php;">
    public static function slugify($text) {
		$text = trim($text);
		$text = str_replace(&quot;.&quot;, &quot;&quot;, $text);
		$text = self::removeAccents($text);
		// replace non letter or digits by -
		$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
		// trim
		$text = trim($text, '-');
		// lowercase
		$text = strtolower($text);
		// remove unwanted characters
		$text = preg_replace('~[^-\w]+~', '', $text);
		return $text;

	}

	public static function removeAccents($text) {
		$text = htmlentities(utf8_decode($text));
		$remove = array(&quot;&amp;amp;&quot;, &quot;acute&quot;, &quot;grave&quot;, &quot;circ&quot;, &quot;tilde&quot;, &quot;uml&quot;);
		$text = str_replace($remove, &quot;&quot;, $text);
		return $text;
	}
</pre>
<p>Put it inside an Utils class, and use it like</p>
<pre class="brush: php;">
$slug = Utils::slugify(&quot;nothingisclear is awesome&quot;);
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.nothingisclear.net/?feed=rss2&amp;p=47</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I really don&#8217;t remember if i wrote it o&#8230;</title>
		<link>http://www.nothingisclear.net/?p=44</link>
		<comments>http://www.nothingisclear.net/?p=44#comments</comments>
		<pubDate>Tue, 23 Mar 2010 21:55:40 +0000</pubDate>
		<dc:creator>reecoo</dc:creator>
				<category><![CDATA[status]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[slug]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.nothingisclear.net/?p=44</guid>
		<description><![CDATA[I really don&#8217;t remember if i&#8217;ve written this or took it from someone on the web (if you recognize it, please let me know, or just know that i didn&#8217;t want to steal it :) ).
Anyway today i was into slugs and i surprisingly found a php simple-and-working static method for converting strings into slugs [...]]]></description>
			<content:encoded><![CDATA[<p>I really don&#8217;t remember if i&#8217;ve written this or took it from someone on the web (if you recognize it, please let me know, or just know that i didn&#8217;t want to steal it :) ).</p>
<p>Anyway today i was into slugs and i surprisingly found a php <u>simple-and-working static method for converting strings into slugs</u> and i felt like sharing it:</p>
<pre class="brush: php;">
/**
 * PHP &quot;iconv&quot; REQUIRED !!!
 * @param object $string
 * @param object $space [optional]
 * @return
 */

public static function convertStringIntoSlug($string,$space=&quot;-&quot;) {  

	if (function_exists('iconv')) {
        $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
    }  

    $string = strtolower(preg_replace(&quot;/[^a-zA-Z0-9 -]/&quot;,&quot;&quot;, $string));
    $string = str_replace(&quot; &quot;, $space, $string);

    return $string;

}
</pre>
<p><a href="http://www.nothingisclear.net/?p=37">here</a> i&#8217;ve already wrote about a good jquery alternative (written by Leo Caseiro) for doing this</p>]]></content:encoded>
			<wfw:commentRss>http://www.nothingisclear.net/?feed=rss2&amp;p=44</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
