I want to wrap tags around the usernames in my tweets so that I can style them a differen't colour and link through to them. For example if this was my tweet:
@benpaton Lorem ipsum dolor sit amet, consectetur adipiscing elit.
I would like to do this:
<a href="http://www.twitter.com/benpaton" target="_blank" class="green">@benpaton</a> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
This is the php I'm using at the moment to render my latest tweet at the moment currently with out links:
<?php
/** Script to pull in the latest tweet */
$username='benpaton'; // set user name
$format='json'; // set format
$tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}")); // get tweets and decode them into a variable
$latestTweet = $tweet[0]->text; // copy the text element from the latest tweet[0] to var $latestTweet
$latestTweet = str_replace("\"","",$latestTweet); // remove speech marks from tweets as this closes the alt tag
?>
Thanks for your help!