190M Music Page
My Music and Playlists
$song\n";
# Exercise 4: MP3 Formatting
$base = basename($song);
print "- \n";
print "$base\n";
# Exercise 6: Song Size Info
$size = filesize($song);
if ($size >= 1024 * 1024) {
$size = (int) ($size / 1024 / 1024) . " MB";
} elseif ($size >= 1024) {
$size = (int) ($size / 1024) . " KB";
} else {
$size = $size . " bytes";
}
print "($size)";
print "
\n";
}
# Exercise 5: Playlist Contents
foreach (glob("songs/*.m3u") as $playlist) {
$base = basename($playlist);
print "- $base:\n";
print "
\n";
$playlist_lines = file($playlist);
foreach ($playlist_lines as $line) {
if (strpos($line, "#") === FALSE) {
print "- $line
\n";
}
}
print "
\n";
print " \n";
}
?>