<?php
function get_tweets($username, $count = 10)
{
	$url = 'http://twitter.com/statuses/user_timeline/'.urlencode($username).'.json?count='.(int)$count;//Make the url
	$ch = curl_init();//Initialise CURL
	curl_setopt($ch, CURLOPT_URL, $url);//Set the url
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);//We want the data to return
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);//Of course, we don't want your script to run forever, so set a timeout
	$json = curl_exec($ch);//Execute and get the page
	curl_close($ch);//Close curl connection

	$decode = json_decode($json);//Decode the json

	$return = array();
	foreach($decode as $tweet)
	{
		$return[] = $tweet -> text;//And the text to an array
	}

	return $return;//Return the array
}

$tweets = get_tweets('barackobama', 10);//Get last 10 tweets of Barack Obama 

//Foreach tweet display it in a new line
foreach($tweets as $tweet)
{
	echo $tweet.'<hr />';
}
?>