Regular expressions filename replace


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.