Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage
Php > Miscellaneous sample source codes
ITunes2
ITunes2 minutes:seconds // I couldn't find any easier ways to do this $minutes = floor(($fields[5] / 60)); $seconds = round(($fields[5] - ($minutes * 60)), 0); if (strlen($seconds) == 1) { $seconds = "0". $seconds; } // format the filesize value from bytes -> kb $size = round(($fields[4]/1024),2); // expore the data, this is all customizable print(" Song - $fields[0]
Artist - $fields[1]
Album - $fields[2]
Genre - $fields[3]
Size - $size K
Time - $minutes:$seconds
Track - $fields[6]/$fields[7]
Date - $fields[9]
Date Added - $fields[10]
Bit Rate - $fields[11]
Sample Rate - $fields[12]
Volume Adjustment - $fields[13]
Kind - $fields[14]
Comments - $fields[15]
"); } } } // *** continueing to work backwards, if no song has been selected, but // but an artist has, display all songs by that particular artist elseif ($artist) { // start a for loop the cycles through the entire file line by line for ($k=1; $k<=count($readfile)-1; $k++) { // split each line into a sepearte array $fields $fields = split("\t",$readfile[$k]); // when we find a line that matches the artist we want this if conditional // trips and prints out a link to the song's info if ($artist == $fields[1]) { print("
$fields[0]
"); } } } // *** continueing to work backwards, if no song has been selected, and // and no artist has been selected, we need to print out a list of artists else { // the $last variable is used within the next for loop, basically, we look at // each line in file and group them together. the first song in the list is // displayed because it does not match "101668871488" (probably) $last = "101668871488"; // start a for loop the cycles through the entire file line by line for ($k=1; $k<=count($readfile)-1; $k++) { // split each line into a sepearte array $fields $fields = split("\t",$readfile[$k]); // print out the artists name with a link to all of their songs if ($last != $fields[1]) { print("
$fields[1]</a>
"); } // this is the trick, at the end of the for loop, we reset $last to this // particular artist. any of the next songs that have the name of $last // will be skipped until we get to a new artist $last = $fields[1]; } } // include an optional footer file if you wish // include("/home/user/public_html/include/footer.inc.php"); ?>
Privacy Policy
|
Link to Us
|
Links