<?php

function CopyTagsToComments(&$getid3->info) {

    
// Copy all entries from ['tags'] into common ['comments'] and ['comments_html']

    
if (@$getid3->info['tags']) {
        
        foreach (
$getid3->info['tags'] as $tag_type => $tag_array) {
        
            foreach (
$tag_array as $tag_name => $tagdata) {
        
                foreach (
$tagdata as $key => $value) {
        
                    if (!empty(
$value)) {
        
                        if (empty(
$getid3->info['comments'][$tag_name])) {

                            
// fall through and append value

                        
} elseif ($tag_type == 'id3v1') {

                            
$new_value_length strlen(trim($value));
                            foreach (
$getid3->info['comments'][$tag_name] as $existing_key => $existing_value) {
                                
$oldvaluelength strlen(trim($existing_value));
                                if ((
$new_value_length <= $oldvaluelength) && (substr($existing_value0$new_value_length) == trim($value))) {
                                    
// new value is identical but shorter-than (or equal-length to) one already in comments - skip
                                    
break 2;
                                }
                            }

                        } else {

                            
$new_value_length strlen(trim($value));
                            foreach (
$getid3->info['comments'][$tag_name] as $existing_key => $existing_value) {
                                
$oldvaluelength strlen(trim($existing_value));
                                if ((
$new_value_length $oldvaluelength) && (substr(trim($value), 0strlen($existing_value)) == $existing_value)) {
                                    
$getid3->info['comments'][$tag_name][$existing_key] = trim($value);
                                    break 
2;
                                }
                            }

                        }
        
                        if (empty(
$getid3->info['comments'][$tag_name]) || !in_array(trim($value), $getid3->info['comments'][$tag_name])) {
                            
$getid3->info['comments'][$tag_name][] = trim($value);
                        }
                    }
                }
            }
        }
        
        
// Copy to ['comments_html'] 
        
foreach ($getid3->info['comments'] as $field => $values) {
            foreach (
$values as $index => $value) {
                
$getid3->info['comments_html'][$field][$index] = str_replace('&#0;'''getid3_lib::MultiByteCharString2HTML($value$getid3->info['encoding']));
            }
        }
    }
}


?>