could save a regex by replacing these 2 lines with preg_replace('/(\.par2|\.rar|\.zip|\.pdf|\.chm|\.mobi\.html|\.rtf|\.txt|\.lit|\.doc|\.nfo|\.sfv)+"/i

also : \.(par2|[a-z]{3}|etc........)+"