<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Parse URL&#8217;s in text, create links</title>
	<atom:link href="http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/feed/" rel="self" type="application/rss+xml" />
	<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/</link>
	<description>The more you know, the more you don't know</description>
	<lastBuildDate>Mon, 19 Dec 2011 12:04:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: ChicagoBrown</title>
		<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/comment-page-1/#comment-3862</link>
		<dc:creator>ChicagoBrown</dc:creator>
		<pubDate>Sun, 20 Mar 2011 05:04:37 +0000</pubDate>
		<guid isPermaLink="false">http://frankkoehl.com/?p=196#comment-3862</guid>
		<description>This code is awesome, thanks for the help!</description>
		<content:encoded><![CDATA[<p>This code is awesome, thanks for the help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/comment-page-1/#comment-3750</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Tue, 04 Aug 2009 20:10:59 +0000</pubDate>
		<guid isPermaLink="false">http://frankkoehl.com/?p=196#comment-3750</guid>
		<description>Here’s an[other] updated linkify() function that turns @account tokens into Twitter account links as well. Let’s hope WordPress doesn’t mangle this one too badly…

&lt;pre style=&quot;overflow:scroll;&quot;&gt;
function linkify( $text ) {
  $text = preg_replace( &#039;/(?!&lt;\S)(\w&#043;:\/\/[^&lt;&gt;\s]&#043;\w)(?!\S)/i&#039;, &#039;&lt;a href=&quot;$1&quot; target=&quot;_blank&quot;&gt;$1&lt;/a&gt;&#039;, $text );
  $text = preg_replace( &#039;/(?!&lt;\S)#(\w&#043;\w)(?!\S)/i&#039;, &#039;&lt;a href=&quot;http://twitter.com/search?q=#$1&quot; target=&quot;_blank&quot;&gt;#$1&lt;/a&gt;&#039;, $text );
  $text = preg_replace( &#039;/(?!&lt;\S)@(\w&#043;\w)(?!\S)/i&#039;, &#039;@&lt;a href=&quot;http://twitter.com/$1&quot; target=&quot;_blank&quot;&gt;$1&lt;/a&gt;&#039;, $text );
  return $text;
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Here’s an[other] updated linkify() function that turns @account tokens into Twitter account links as well. Let’s hope WordPress doesn’t mangle this one too badly…</p>
<pre style="overflow:scroll;">
function linkify( $text ) {
  $text = preg_replace( '/(?!&lt;\S)(\w&#43;:\/\/[^&lt;&gt;\s]&#43;\w)(?!\S)/i', '&lt;a href="$1" target="_blank"&gt;$1&lt;/a&gt;', $text );
  $text = preg_replace( '/(?!&lt;\S)#(\w&#43;\w)(?!\S)/i', '&lt;a href="http://twitter.com/search?q=#$1" target="_blank"&gt;#$1&lt;/a&gt;', $text );
  $text = preg_replace( '/(?!&lt;\S)@(\w&#43;\w)(?!\S)/i', '@&lt;a href="http://twitter.com/$1" target="_blank"&gt;$1&lt;/a&gt;', $text );
  return $text;
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/comment-page-1/#comment-3745</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Fri, 31 Jul 2009 01:53:11 +0000</pubDate>
		<guid isPermaLink="false">http://frankkoehl.com/?p=196#comment-3745</guid>
		<description>I&#039;ve updated the linkify() function to include support for turning #hashtags into links as well (excuse my having converted from ereg_* to preg_* - just a comfort-zone thing).

&lt;pre&gt;
function linkify( $text ) {
  $text = preg_replace( &#039;/(?!&lt;\S)(\w+:\/\/[^&lt;&gt;\s]+\w)(?!\S)/i&#039;, &#039;&lt;a href=&quot;$1&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;$1&lt;/a&gt;&#039;, $text );
  $text = preg_replace( &#039;/(?!&lt;\S)#(\S+\w)(?!\S)/i&#039;, &#039;&lt;a href=&quot;http://twitter.com/search?q=%23$1&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;#$1&lt;/a&gt;&#039;, $text );
  return $text;
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I&#8217;ve updated the linkify() function to include support for turning #hashtags into links as well (excuse my having converted from ereg_* to preg_* &#8211; just a comfort-zone thing).</p>
<pre>
function linkify( $text ) {
  $text = preg_replace( '/(?!< \S)(\w+:\/\/[^<>\s]+\w)(?!\S)/i', '<a href="$1" target="_blank" rel="nofollow">$1</a>', $text );
  $text = preg_replace( '/(?!< \S)#(\S+\w)(?!\S)/i', '<a href="http://twitter.com/search?q=%23$1" target="_blank" rel="nofollow">#$1', $text );
  return $text;
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/comment-page-1/#comment-3429</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 15 Jul 2009 01:40:18 +0000</pubDate>
		<guid isPermaLink="false">http://frankkoehl.com/?p=196#comment-3429</guid>
		<description>Stupid Wordpress editor mangled the code. It&#039;s fixed, try the above.</description>
		<content:encoded><![CDATA[<p>Stupid WordPress editor mangled the code. It&#8217;s fixed, try the above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/comment-page-1/#comment-3427</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Wed, 15 Jul 2009 01:37:14 +0000</pubDate>
		<guid isPermaLink="false">http://frankkoehl.com/?p=196#comment-3427</guid>
		<description>Here is my Entire Code...  Works great, check out the Links Page of my site...

http://thefoxxfamily.com/

CODE:

&lt;?php
  function twitter_status($twitter_id, $hyperlinks = true) {
  $c = curl_init();
  curl_setopt($c, CURLOPT_URL, &quot;http://twitter.com/statuses/user_timeline/15456263.xml&quot;);
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 3);
  curl_setopt($c, CURLOPT_TIMEOUT, 5);
  $response = curl_exec($c);
  $responseInfo = curl_getinfo($c);
  curl_close($c);
  if (intval($responseInfo[&#039;http_code&#039;]) == 200) {
    if (class_exists(&#039;SimpleXMLElement&#039;)) {
      $xml = new SimpleXMLElement($response);
      return $xml;
    } else {
      return $response;
    }
  } else {
    return false;
  }
}
  
function linkify_twitter_status($status_text)
{
  // linkify URLs
  $status_text = preg_replace(
    &#039;/(https?:\/\/\S )/&#039;,
    &#039;&lt;a href=&quot;\1&quot; rel=&quot;nofollow&quot;&gt;\1&lt;/a&gt;&#039;,
    $status_text
  );

  // linkify twitter users
  $status_text = preg_replace(
    &#039;/(^&#124;\s)@(\w )/&#039;,
    &#039;\1@&lt;a href=&quot;http://twitter.com/\2&quot; rel=&quot;nofollow&quot;&gt;\2&lt;/a&gt;&#039;,
    $status_text
  );

  // linkify tags
  $status_text = preg_replace(
    &#039;/(^&#124;\s)#(\w )/&#039;,
    &#039;\1#&lt;a href=&quot;http://search.twitter.com/search?q=#\2&quot; rel=&quot;nofollow&quot;&gt;\2&lt;/a&gt;&#039;,
    $status_text
  );

  return $status_text;
}

  
 if ( $twitter_xml = twitter_status(&#039;12345678&#039;) ) {
    date_default_timezone_set(&#039;GMT&#039;);
    $tz = new DateTimeZone(&#039;America/New_York&#039;);
    $i = 0;
    foreach ($twitter_xml-&gt;status as $key =&gt; $status) {
      $datetime = new DateTime($status-&gt;created_at);
      $datetime-&gt;setTimezone($tz);
      $time_display = $datetime-&gt;format(&#039;D, M jS g:ia T&#039;);
?&gt;
  text) . &#039;&#039; . $time_display; ?&gt;

  &lt;a href=&quot;http://twitter.com/danfoxx&quot; rel=&quot;nofollow&quot;&gt;read more updates...&lt;/a&gt;
</description>
		<content:encoded><![CDATA[<p>Here is my Entire Code&#8230;  Works great, check out the Links Page of my site&#8230;</p>
<p><a href="http://thefoxxfamily.com/" rel="nofollow">http://thefoxxfamily.com/</a></p>
<p>CODE:</p>
<p>&lt;?php<br />
  function twitter_status($twitter_id, $hyperlinks = true) {<br />
  $c = curl_init();<br />
  curl_setopt($c, CURLOPT_URL, &quot;<a href="http://twitter.com/statuses/user_timeline/15456263.xml&#038;quot" rel="nofollow">http://twitter.com/statuses/user_timeline/15456263.xml&#038;quot</a> <img src='http://frankkoehl.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ;<br />
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);<br />
  curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 3);<br />
  curl_setopt($c, CURLOPT_TIMEOUT, 5);<br />
  $response = curl_exec($c);<br />
  $responseInfo = curl_getinfo($c);<br />
  curl_close($c);<br />
  if (intval($responseInfo[&#039;http_code&#039;]) == 200) {<br />
    if (class_exists(&#039;SimpleXMLElement&#039;)) {<br />
      $xml = new SimpleXMLElement($response);<br />
      return $xml;<br />
    } else {<br />
      return $response;<br />
    }<br />
  } else {<br />
    return false;<br />
  }<br />
}</p>
<p>function linkify_twitter_status($status_text)<br />
{<br />
  // linkify URLs<br />
  $status_text = preg_replace(<br />
    &#039;/(https?:\/\/\S )/&#039;,<br />
    &#039;<a href="\1" rel="nofollow">\1</a>&#8216;,<br />
    $status_text<br />
  );</p>
<p>  // linkify twitter users<br />
  $status_text = preg_replace(<br />
    &#8216;/(^|\s)@(\w )/&#8217;,<br />
    &#8216;\1@<a href="http://twitter.com/\2" rel="nofollow">\2</a>&#8216;,<br />
    $status_text<br />
  );</p>
<p>  // linkify tags<br />
  $status_text = preg_replace(<br />
    &#8216;/(^|\s)#(\w )/&#8217;,<br />
    &#8216;\1#<a href="http://search.twitter.com/search?q=#\2" rel="nofollow">\2</a>&#8216;,<br />
    $status_text<br />
  );</p>
<p>  return $status_text;<br />
}</p>
<p> if ( $twitter_xml = twitter_status(&#8217;12345678&#8242;) ) {<br />
    date_default_timezone_set(&#8216;GMT&#8217;);<br />
    $tz = new DateTimeZone(&#8216;America/New_York&#8217;);<br />
    $i = 0;<br />
    foreach ($twitter_xml-&gt;status as $key =&gt; $status) {<br />
      $datetime = new DateTime($status-&gt;created_at);<br />
      $datetime-&gt;setTimezone($tz);<br />
      $time_display = $datetime-&gt;format(&#8216;D, M jS g:ia T&#8217;);<br />
?&gt;<br />
  text) . &#8221; . $time_display; ?&gt;</p>
<p>  <a href="http://twitter.com/danfoxx" rel="nofollow">read more updates&#8230;</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/comment-page-1/#comment-3416</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Tue, 14 Jul 2009 22:27:12 +0000</pubDate>
		<guid isPermaLink="false">http://frankkoehl.com/?p=196#comment-3416</guid>
		<description>I tried this.  I changed the name of variable from $t to $tweettext and then I updated the ereg_replace statement.

function linkify($tweettext) {
  $tweettext = ereg_replace(&quot;[[:alpha:]] ://[^[:space:]] [[:alnum:]/]&quot;,&quot;&lt;a href=&quot;\&quot; rel=&quot;nofollow&quot;&gt;\&lt;/a&gt;&quot;, $tweettext);
  return $tweettext;
}

It worked for me.  Although I am real interested to see how Dan&#039;s solution works.</description>
		<content:encoded><![CDATA[<p>I tried this.  I changed the name of variable from $t to $tweettext and then I updated the ereg_replace statement.</p>
<p>function linkify($tweettext) {<br />
  $tweettext = ereg_replace(&#8220;[[:alpha:]] ://[^[:space:]] [[:alnum:]/]&#8221;,&#8221;<a href="\" rel="nofollow">\</a>&#8220;, $tweettext);<br />
  return $tweettext;<br />
}</p>
<p>It worked for me.  Although I am real interested to see how Dan&#8217;s solution works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/comment-page-1/#comment-3414</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Tue, 14 Jul 2009 21:50:14 +0000</pubDate>
		<guid isPermaLink="false">http://frankkoehl.com/?p=196#comment-3414</guid>
		<description>I too had some issues with the original code.  Dan, I tried your code and still could not get it to work.  Are you still using the same output method?</description>
		<content:encoded><![CDATA[<p>I too had some issues with the original code.  Dan, I tried your code and still could not get it to work.  Are you still using the same output method?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://frankkoehl.com/2008/12/parse-urls-in-text-create-links/comment-page-1/#comment-3412</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 14 Jul 2009 21:26:42 +0000</pubDate>
		<guid isPermaLink="false">http://frankkoehl.com/?p=196#comment-3412</guid>
		<description>Had trouble with your code, lost the link text and it Linked ever Tweet below with a false link.  I tried this out and it worked Great, not sure the difference...
(It links the Hash Tags and the @danfoxx too.)

function linkify($status_text)
{
  // linkify URLs
  $status_text = preg_replace(
    &#039;/(https?:\/\/\S )/&#039;,
    &#039;&lt;a href=&quot;\1&quot; rel=&quot;nofollow&quot;&gt;\1&lt;/a&gt;&#039;,
    $status_text
  );

  // linkify twitter users
  $status_text = preg_replace(
    &#039;/(^&#124;\s)@(\w )/&#039;,
    &#039;\1@&lt;a href=&quot;http://twitter.com/\2&quot; rel=&quot;nofollow&quot;&gt;\2&lt;/a&gt;&#039;,
    $status_text
  );

  // linkify tags
  $status_text = preg_replace(
    &#039;/(^&#124;\s)#(\w )/&#039;,
    &#039;\1#&lt;a href=&quot;http://search.twitter.com/search?q=#\2&quot; rel=&quot;nofollow&quot;&gt;\2&lt;/a&gt;&#039;,
    $status_text
  );

  return $status_text;
}</description>
		<content:encoded><![CDATA[<p>Had trouble with your code, lost the link text and it Linked ever Tweet below with a false link.  I tried this out and it worked Great, not sure the difference&#8230;<br />
(It links the Hash Tags and the @danfoxx too.)</p>
<p>function linkify($status_text)<br />
{<br />
  // linkify URLs<br />
  $status_text = preg_replace(<br />
    &#8216;/(https?:\/\/\S )/&#8217;,<br />
    &#8216;<a href="\1" rel="nofollow">\1</a>&#8216;,<br />
    $status_text<br />
  );</p>
<p>  // linkify twitter users<br />
  $status_text = preg_replace(<br />
    &#8216;/(^|\s)@(\w )/&#8217;,<br />
    &#8216;\1@<a href="http://twitter.com/\2" rel="nofollow">\2</a>&#8216;,<br />
    $status_text<br />
  );</p>
<p>  // linkify tags<br />
  $status_text = preg_replace(<br />
    &#8216;/(^|\s)#(\w )/&#8217;,<br />
    &#8216;\1#<a href="http://search.twitter.com/search?q=#\2" rel="nofollow">\2</a>&#8216;,<br />
    $status_text<br />
  );</p>
<p>  return $status_text;<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

