Улучшение канала Twitter JSON

Я работаю над фида Twitter для моего веб-сайта . До сих пор я выяснил, как вывести дату, но то, что я ищу, – это выбрать URL-адреса и гиперссылки. Я также хотел бы выделить #hashtags, гиперссылку на них для поиска твиттера. Я только начинаю изучать PHP, поэтому любая помощь будет оценена по достоинству.

<?php $count = 5; $tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/atrueresistance.json?count=".$count."" )); for ($i=1; $i <= $count; $i++){ echo "<div class='tweet'>".$tweet[($i-1)]->text." <div class='tweet_date'>". date("M \- j",strtotime($tweet[($i-1)]->created_at))." </div> </div>"; } ?> 

Поскольку никто не реагирует на это, я решил, что пришло время, когда я поставил код, с которым я столкнулся.

Наслаждайтесь!

 <?php $count = 5; $tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/atrueresistance.json?count=".$count."" )); for ($i=1; $i <= $count; $i++){ //Assign feed to $feed $feed = $tweet[($i-1)]->text; //Find location of @ in feed $feed = str_pad($feed, 3, ' ', STR_PAD_LEFT); //pad feed $startat = stripos($feed, '@'); $numat = substr_count($feed, '@'); $numhash = substr_count($feed, '#'); $numhttp = substr_count($feed, 'http'); $feed = preg_replace("/(http:\/\/)(.*?)\/([\w\.\/\&\=\?\-\,\:\;\#\_\~\%\+]*)/", "<a href=\"\\0\">\\0</a>", $feed); $feed = preg_replace("(@([a-zA-Z0-9\_]+))", "<a href=\"http://www.twitter.com/\\1\">\\0</a>", $feed); $feed = preg_replace('/(^|\s)#(\w+)/', '\1<a href="http://search.twitter.com/search?q=%23\2">#\2</a>', $feed); echo "<div class='tweet'>".$feed. "<div class='tweet_date'>". date("M \- j",strtotime($tweet[($i-1)]->created_at))." </div></div>"; }?>