Posted By

andyhartleeds on 09/12/07


Tagged

replace regular expressions filename pregreplace pcre


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

vali29
lisandro
mad9scientist
wirenaught


Regular expressions filename replace


 / Published in: PHP
 

Strip out non-alphanumeric characters. Very useful for use with filenames.

  1. // This will strip out any punctuation and spaces from filenames, replacing such characters with underscores
  2. $filename = preg_replace("/[^a-zA-Z0-9s.]/", "_", $filename);

Report this snippet  

You need to login to post a comment.