Read mp3 file's information with php
Monday, May 26, 2014
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 = "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: PHP
Post a Comment