Skip to content

Instantly share code, notes, and snippets.

@invmatt
Last active December 30, 2015 05:49
Show Gist options
  • Select an option

  • Save invmatt/7785237 to your computer and use it in GitHub Desktop.

Select an option

Save invmatt/7785237 to your computer and use it in GitHub Desktop.
Retrieve the JSON tweet text and replace all @username with links to profile. (using https://docs.google.com/file/d/0B6SP5Ft5Ty22SmJjSE9WOHh0RmM/edit?pli=1)
<?php
// Match Twitter handles and create a link to the profile
$string = $value["text"];
$input = preg_replace('/(?<=^|\s)@([a-z0-9_]+)/i', '<a href="http://www.twitter.com/$1">@$1</a>', $string);
echo $input;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment