Return to Snippet

Revision: 68703
at February 13, 2015 11:32 by flatearthcomms


Initial Code
$filename=trim($_FILES['pdf']['name']);
$name = preg_replace('/[^a-z0-9.]+/', '_', strtolower($filename));

Initial URL
http://stackoverflow.com/questions/1725104/reg-exp-wanted-for-replacing-all-non-alphanumeric-chars-with-underscores

Initial Description
Translate non alphanumeric characters into an underscore. Doesn't create double underscores if there's two spaces in a row. Also turns name to lowercase. Use with trim to avoid spaces at front or end.

Initial Title
translate non alphanumeric characters from file name into underscores

Initial Tags
form, php, web

Initial Language
PHP