id3_get_version

id3_get_version

(PECL)

id3_get_version -- Get version of an ID3 tag

Description

int id3_get_version ( string filename )

id3_get_version() retrieves the version(s) of the ID3 tag(s) in the MP3 file. As a tag can contain ID3 v1.x and v2.x tags, the return value of this function should be bitwise compared with the predefined constants ID3_V1_0, ID3_V1_1 and ID3_V2.

Note: Instead of a filename you may also pass a valid stream resource.

Example 1. id3_get_version() example

<?php
$version
= id3_get_version( "path/to/example.mp3" );
if (
$version & ID3_V1_0) {
    echo
"Contains a 1.x tag\n";
}
if (
$version & ID3_V1_1) {
    echo
"Contains a 1.1 tag\n";
}
if (
$version & ID3_V2) {
    echo
"Contains a 2.x tag\n";
}
?>

This will output something like:

Contains a 1.x tag
Contains a 1.1 tag

If a file contains an ID3 v1.1 tag, it always contains a 1.0 tag, as version 1.1 is just an extension of 1.0.

See also id3_get_tag(), id3_set_tag() and id3_remove_tag().

© Copyright 2003-2014 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.