I couldn't get this to work in Windows XP. Windows users may be interested to note that the following bug with Windows, reported in Feb 2006, appears not to have been fixed yet.
http://pecl.php.net/bugs/search.php?
cmd=display&status=Open&package_name[]=id3
(NB you'll have to concat the two lines above)
id3_get_tag
(PECL id3:0.1-0.2)
id3_get_tag — ID3 タグに含まれるすべての情報を取得する
説明
array id3_get_tag ( string $filename [, int $version] )id3_get_tag() は、指定したファイルの ID3 タグに 含まれるすべての情報を取得するために使用されます。
パラメータ
- filename
MP3 ファイルへのパス。
ファイル名のかわりに、ストリームリソースを渡すことも可能です。
- version
MP3 ファイルがバージョン 1.x およびバージョン 2.x の両方のタグを 含んでいる場合に、タグのバージョンを指定します。
バージョン 0.2 以降、id3_get_tag() は ID3 タグのバージョン 2.2、2.3 および 2.4 にも対応するようになりました。 これらのタグに関する情報を取得するには、2 番目の引数に ID3_V2_2、ID3_V2_3 あるいは ID3_V2_4 のいずれかの定数を指定します。 ID3 v2.x タグは、ID3 v1.x タグに比べてはるかに多くの情報を MP3 ファイルに含めることが可能です。
返り値
title や artist といったキーを含む連想配列を返します。
genre には 0 から 147 までの整数値が格納されています。 id3_get_genre_name() を使用することで、 この数値をジャンル名に変換することが可能です。
例
例 943. id3_get_tag() の例
<?php
$tag = id3_get_tag( "path/to/example.mp3" );
print_r($tag);
?>
上の例の出力は、たとえば 以下のようになります。
Array
(
[title] => DN-38416
[artist] => Re:\Legion
[album] => Reflections
[year] => 2004
[genre] => 19
)
例 944. id3_get_tag() の例
<?php
$tag = id3_get_tag( "path/to/example2.mp3", ID3_V2_3 );
print_r($tag);
?>
上の例の出力は、たとえば 以下のようになります。
Array
(
[copyright] => Dirty Mac
[originalArtist] => Dirty Mac
[composer] => Marcus Gze
[artist] => Dirty Mac
[title] => Little Big Man
[album] => Demo-Tape
[track] => 5/12
[genre] => (17)Rock
[year] => 2001
)
参考
| id3_set_tag() |
| id3_remove_tag() |
| id3_get_version() |
id3_get_tag
07-Nov-2006 11:25