$lastfmUsername = $userinfo['field8']; $numberOfSongs = 10; // 10 is max if (strlen($lastfmUsername) > 2) { $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, "http://ws.audioscrobbler.com/1.0/user/$lastfmUsername/recenttracks.txt"); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $recentlyPlayedSongs = curl_exec($ch); curl_close($ch); $track = explode("\n", $recentlyPlayedSongs); for ($i = 0; $i < $numberOfSongs; $i++) { $trackArray = explode(",", $track[$i]); $tracks .= $trackArray[1]."
"; } }