Ereg() would be an excellent choice.
To move a step further, although it is a little more complex to become familiar with, the perl regular expressions are considerably faster and more efficient for anything with an expression, and str_replace() is faster yet, if replacing a simple string. Thus, it would probably be best to use: $clean_term = str_replace( " ", "_", $term); // replace spaces with _ $clean_term = preg_replace("@[^a-zA-Z0-9_.]@", "", $term); // remove any non-alphanumeric chars There is an excellent article somewhere that gives some benchmark times for the various methods... Anyone know where this is? I can't seem to find it anymore. However, I remember the basic concept: on a given string, preg_replace ran about 1 second, ereg_replace ran about 4 seconds, and str_replace ran about .2 seconds. See these docs for info about syntax: http://www.php.net/manual/en/function.preg-replace.php http://www.php.net/manual/en/function.str-replace.php http://www.php.net/manual/en/function.ereg-replace.php Best wishes Michael "phpzen" -----Original Message----- From: Rodolfo Gonzalez [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 05, 2002 9:34 AM To: Javier Montserat Cc: [EMAIL PROTECTED] Subject: Re: [PHP] formatting a filename On Thu, 5 Sep 2002, Javier Montserat wrote: > i want to format the filename of an uploaded file as follows :- > -- replace blankspace with "_" > -- remove any illegal characters. > Which string functions should I use to do this? http://www.php.net/manual/en/function.ereg.php http://www.php.net/manual/en/function.ereg.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php