RE: [PHP] string validating
| From: | John W. Holmes | Date: | Thu, 13 Mar 2003 01:22:57 +0000 |
| Subject: | RE: [PHP] string validating | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139421@lists.php.net to get a copy of this message | ||
> im reading in a string from a database, this string will become a file
> name.
> so i need to strip everything BUT lowercase a-z and 0-9. well im
> strtolower
> so i dont need to worry about upper case. blank spaces get replaced
with _
$filename = preg_replace("/[^a-z0-9]/","_",$data);
Replace _ with whatever you want to replace anything that's not (^) a-z
or 0-9.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/