Motyar

@motyar

Freelance Web Developer

Static Web Hosting, made easy

Dec 14, 2012

Read mp3 file info with PHP

I know there are a lot of PHP libraries out there you can use to read ID3 tags from a MP3 file. But here is the simplest one.

$file = "path/to/file.mp3";
$data = file_get_contents($file);
if(substr($data, -128, -125)=="TAG"){
 echo "Title: ".substr($data, -125, -95);
 echo "Artist: ".substr($data, -95, -65);
 echo "Album: ".substr($data, -65, -35);
 echo "Year: ".substr($data, -35, -31);
 echo "Comment: ".substr($data, -31, -1);
 echo "Genre: ".$genre_arr[ord(substr($data, -1, 1))];
 }

Labels: ,




By :