<?php header("Content-type: text/plain; charset= UTF-8"); // Sets the type of response provided, and the character set used $recent = file( "" ); // The URL to your last.fm info. While logged in to last.fm, go to "http://www.last.fm/onyoursite/datafeeds.php" and click on Recent Tracks -> Text. The URL of the resultatn file is your url to enter here. $user = ""; // Your desired display name $lasttrack = rtrim ( substr( $recent[0], 11 ) ); // Gets the information after the timestamp of the last submission time, and gets rid of the newline at the end. $parse = explode( " - ", $lasttrack, 2 ); // Splits this data into an array. list( $artist, $title ) = $parse; // Takes the array and assigns the data to variables to be used later. $when = substr( $recent[0], 0, 10 ); // Gets the timestamp. $since = time( ) - $when; // Checks the difference between the last submission, and when this script is run. if ( $since < 3600 ) // Checks to see if the time since the last track was played was under an hour. { $howlong = $since / 60; $howlong = number_format( $howlong, 2 ); $howlong .= " minute(s) ago."; } elseif ( $since >= 3600 && $since < 86400 ) // Checks to see if the time since the last track was played was between an hour and a day, only if longer than an hour. { $howlong = $since / 3600; $howlong = number_format($howlong, 2); $howlong .= " hour(s) ago."; } elseif ( $since >= 86400 ) // Checks to see if the time is longer than 1 day, only if it's more than 24 hours worth. { $howlong = $since / 86400; $howlong = number_format( $howlong, 2 ); $howlong .= " day(s) ago."; } else // Default statement to cover an error in the data. { echo $howlong = "Error: timestamp data conflicts. Please check the settings of your server."; } echo $user . " listened to the song [" . $title . "] by [". $artist . "] about " . $howlong; // displays the information.?>