if (substr($attachment['filename'], -4) === ".txt") $attachment['filename'] = "get file"; else if (substr($attachment['filename'], -4) === ".rar") $attachment['filename'] = "get archive";