Hello, I have a text field, which creates a file name for an XML file. It then takes that XML file and throws it on my server to download. When a user types the file name with spaces, it throws the application off. I need a simple function that removes spaces from words. e.g. Before: My File Name After: MyFileName I know its a simple solution, Thank You! -Tim
I would suggest using preg_replace() because the user might enter other characters that are not allowed in file names. $name = preg_replace('~[^\w-\.]+~', '', $name); PHP: This for example would replace everything except alphanumeric characters, dashes, underscores, and periods.