How to extract information from mp3 files using php _ PHP Tutorial

Source: Internet
Author: User
How to use php to extract information from mp3 files. Today, I saw a small software from Han Yu studio that could extract the mp3 file information in the specified directory and generate a webpage. the function is very simple, but it is very practical, so I thought of today, seeing a small software from Han Yu studio, I can extract the mp3 file information under the specified directory and generate a webpage. the function is very simple, but it is very practical, so I thought that I could use php to implement this function, so I went to work.
We first open several mp3 files in a text editor. although all the files are garbled, we find that there is a TAG at the last point, followed by various information about the mp3 file, including the artist, album name, time, and some website information (of course, some files do not exist. you can use winamp to add the album. The details are not described.) haha, I feel very good, the next step is how to extract the information.
Before extracting information, we need to find the mp3 file in the specified directory. The following is the code snippet for extracting the mp3 file:
$ Thisdir = dir (".");
While ($ file = $ thisdir-> read ()){
If ((! Is_dir ("./$ file") and ($ file! = ".") And ($ file! = ".."))
{
$ Mp3 = strstr ($ file ,".");
If ($ mp3 = ". mp3 "){
Echo"
  • $ File
  • ";
    Echo "";
    }
    }
    This code can display the mp3 file in the specified directory (The Directory of the file to be saved in the example ).
    The next step is to extract the information from the extracted mp3 file. The following is a program snippet:
    $ Fp = fopen ($ file, "r ");
    $ Content = fread ($ fp, filesize ($ file ));
    $ Content = strstr ($ content, "TAG ");
    Echo "$ content ";
    Because the information starts with a TAG string, we use the strstr function to find the first tag to appear, and then display the subsequent string. this is the information in the mp3 file. of course, this information is messy. you can use the string function to analyze and process the extracted information to obtain useful information. The specifics are left for the readers to think about.

    ...

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.