Twitter @reply and urls to links


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $text = utf8_decode( $results[ $i ][ "text" ] );
  2. $text = preg_replace('@(https?://([-\w\.]+)+(d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text );
  3. $text = preg_replace("#(^|[\n ])@([^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://www.twitter.com/\\2\" >@\\2</a>'", $text);
  4. $text = preg_replace("#(^|[\n ])\#([^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://hashtags.org/search?query=\\2\" >#\\2</a>'", $text);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.