Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:49:39+00:00 2026-06-12T18:49:39+00:00

i am using below code to print the id3 tags of MP2 files but

  • 0

i am using below code to print the id3 tags of MP2 files but the output is coming in this form

Array ( [FileName] => 4.mp3 [TAG] => ID3 [Version] => 3.0 [Title] => &Bahut Khubsurat Ghazal (mr-Jatt.Com) [Album] => 1Loverz Choice (A Khubsurat Ghazal) (www.mzc.in) [Author] => DJ Badboy (mr-Jatt.Com) [Track] => (www.mzc.in) ) 

but i want plain output like this

FileName 4.mp3 Title Bahut Khubsurat Ghazal (mr-Jatt.Com) Album 1Loverz Choice (A Khubsurat Ghazal) (www.mzc.in) Author DJ Badboy (mr-Jatt.Com) Track (www.mzc.in)

my code is

print_r(tagReader("4.mp3"));
// ------------------------------
function tagReader($file) {
    $id3v23 = array("TIT2","TALB","TPE1","TRCK","TDRC","TLEN","USLT");
    $id3v22 = array("TT2","TAL","TP1","TRK","TYE","TLE","ULT");
    $fsize = filesize($file);
    $fd = fopen($file, "r");
    $tag = fread($fd, $fsize);
    $tmp = "";
    fclose($fd);
    if (substr($tag, 0, 3) == "ID3") {
        $result['FileName'] = $file;
        $result['TAG'] = substr($tag, 0, 3);
        $result['Version'] = hexdec(bin2hex(substr($tag, 3, 1))) . "." . hexdec(bin2hex(substr($tag, 4, 1)));
    }
    if ($result['Version'] == "4.0" || $result['Version'] == "3.0") {
        for($i = 0; $i < count($id3v23); $i ++) {
            if (strpos($tag, $id3v23[$i] . chr(0)) != FALSE) {
                $pos = strpos($tag, $id3v23[$i] . chr(0));
                $len = hexdec(bin2hex(substr($tag, ($pos + 5), 3)));
                $data = substr($tag, $pos, 9 + $len);
                for($a = 0; $a < strlen($data); $a ++) {
                    $char = substr($data, $a, 1);
                    if ($char >= " " && $char <= "~")
                        $tmp .= $char;
                }
                if (substr($tmp, 0, 4) == "TIT2")
                    $result['Title'] = substr($tmp, 4);
                if (substr($tmp, 0, 4) == "TALB")
                    $result['Album'] = substr($tmp, 4);
                if (substr($tmp, 0, 4) == "TPE1")
                    $result['Author'] = substr($tmp, 4);
                if (substr($tmp, 0, 4) == "TRCK")
                    $result['Track'] = substr($tmp, 4);
                if (substr($tmp, 0, 4) == "TDRC")
                    $result['Year'] = substr($tmp, 4);
                if (substr($tmp, 0, 4) == "TLEN")
                    $result['Lenght'] = substr($tmp, 4);
                if (substr($tmp, 0, 4) == "USLT")
                    $result['Lyric'] = substr($tmp, 7);
                $tmp = "";
            }
        }
    }
    if ($result['Version'] == "2.0") {
        for($i = 0; $i < count($id3v22); $i ++) {
            if (strpos($tag, $id3v22[$i] . chr(0)) != FALSE) {
                $pos = strpos($tag, $id3v22[$i] . chr(0));
                $len = hexdec(bin2hex(substr($tag, ($pos + 3), 3)));
                $data = substr($tag, $pos, 6 + $len);
                for($a = 0; $a < strlen($data); $a ++) {
                    $char = substr($data, $a, 1);
                    if ($char >= " " && $char <= "~")
                        $tmp .= $char;
                }
                if (substr($tmp, 0, 3) == "TT2")
                    $result['Title'] = substr($tmp, 3);
                if (substr($tmp, 0, 3) == "TAL")
                    $result['Album'] = substr($tmp, 3);
                if (substr($tmp, 0, 3) == "TP1")
                    $result['Author'] = substr($tmp, 3);
                if (substr($tmp, 0, 3) == "TRK")
                    $result['Track'] = substr($tmp, 3);
                if (substr($tmp, 0, 3) == "TYE")
                    $result['Year'] = substr($tmp, 3);
                if (substr($tmp, 0, 3) == "TLE")
                    $result['Lenght'] = substr($tmp, 3);
                if (substr($tmp, 0, 3) == "ULT")
                    $result['Lyric'] = substr($tmp, 6);
                $tmp = "";
            }
        }
    }
    return $result;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:49:40+00:00Added an answer on June 12, 2026 at 6:49 pm

    You can try

    foreach ( tagReader("4.mp3") as $name => $value ) {
        printf("<p>%s:%s</p>", $name, $value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the code below to print from an array but its printing
In the example below, if client code using GetPeople wanted to print the name
I'm using below code to check some form fields and render datatable table on
I am using below code for Embed MP3 Audio Files In Web Pages, <embed
i am using below code to print my content of webpage in asp.net using
Thanks in advance. Getting this warning when using below code: Warning: file_get_contents(test.php) [function.file-get-contents]: failed
I'm using the code below to print out rows containing 4 columns. How would
I have two files I merged them based key using below code file1 -------------------------------
I am using the below mentioned code in my VB.net application to print two
I am currently using the below code to run a process and print its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.