Basically what you need to do is create an array of the characters you do not want in the file, then loop through the filename one character at a time. Then use the function stripos to check if the current character is in the not allowable list if it is return false. If you have gone through all the characters in the file then you return true.