My list of genres doesn't match the genre in getID3... Why?

The place for "I can't figure out how to..." questions.
Post Reply
nakkeli
User
Posts: 7
Joined: Wed Jun 04, 2008 8:13 pm

My list of genres doesn't match the genre in getID3... Why?

Post by nakkeli » Mon Jun 09, 2008 6:09 am

I made a .txt file of all the (winamp approved) ID3 v1 genres, and then I load it into an array:

Code: Select all

$handle = @fopen("id3v1_genres.txt", "r");
if ($handle) {
  while (!feof($handle)) {
    $buffer = fgets($handle, 4096);
    $genrelist[] = $buffer;
  }
  fclose($handle);
}
And then I make a genre dropdown list, where user can set the genre and this should also select the right genre (what is read from mp3 file)...

Code: Select all

echo '<select id="genres" name="txtgenre">' . "\n";
foreach($genrelist as $genre) {
  if ($genre == @$ThisFileInfo['tags']['id3v1']['genre'][0]) {
    echo '<option selected="selected">' . $genre . '</option>' . "\n";
  }
  else {
    echo '<option>' . $genre . '</option>' . "\n";
  }
}
echo '</select>' . "\n";
But this does not work. Why is this? I noticed that for some reason I get an extra space into the array items, but even after ltrim/rtrim spaces, they do not match... :(

James Heinrich
getID3() v1 developer
Posts: 1477
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Post by James Heinrich » Mon Jun 09, 2008 10:28 am

Case-sensitive? Typos? Different spelling or formatting?
Do they all not match, or only some of them? If some, which ones don't match?

The other alternative would be to use getID3's own list of genres:

Code: Select all

require_once('getid3/module.tags.id3v1.php');
$genrelist = getid3_id3v1::ArrayOfGenres();
// etc.

nakkeli
User
Posts: 7
Joined: Wed Jun 04, 2008 8:13 pm

Post by nakkeli » Tue Jun 10, 2008 5:19 am

I have no idea why it didn't work. I can see a space in that drop-down list... Oh well, you had a better idea, so I'm using that and it works :)

Post Reply