Simple solution to display Tweets with PHP

load($myFile);

$items = $dom->getElementsByTagName('item');

$count = 0;

foreach ($items as $item) {
// Select all the elements in the XML document
// Elements available are Title, Description, pubDate, guid, link and twitter:source

$tweets = $item->getElementsByTagName('description');
$tweet_string = $tweets->item(0)->nodeValue;
$tweet_string = substr($tweet_string,strpos($tweet_string,":")+2);

/*******DATE OF TWEET EXAMPLE*******/
/*$tweet_date = $item->getElementsByTagName('pubDate');
$tweet_date = $tweet_date->item(0)->nodeValue;
$tweet_date = substr($tweet_date,0,16);*/

echo ("

  • ".makelink($tweet_string)."
  • ");

    $count = $count+1;
    if ($count>=$max_items){ break; }
    }
    }

    function makeLink($string){
    // Function to convert url to a link

    /*** Checking for http:// on all URLs ***/
    $string = preg_replace("/([^w/])(www.[a-z0-9-]+.[a-z0-9-]+)/i", "$1http://$2",$string);

    /*** Creates Links ***/
    $string = preg_replace("/([w]+://[w-?&;#~=./@]+[w/])/i","$1",$string);

    /*** Creates Email Links ***/
    $string = preg_replace("/([w-?&;#~=./]+@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?))/i","$1",$string);

    return $string;
    }

    /*******DISPLAY THE TWEET(S)*******/
    echo "

      ";
      echo twitter_status();
      echo "

    ";
    ?>