Posted By

punuhan on 04/15/11


Tagged

php


Versions (?)

Remove special characters from file name


 / Published in: PHP
 

The special characters in the file name caused problem when the exported to iphone application.

  1. function remove_special_char($string) {
  2. $ts = array("/\~/", "/\`/", "/\@/", "/\#/", "/\\$/", "/\%/", "/\^/", "/\&/", "/\*/", "/\(/", "/\)/", "/\:/", "/\:/", "/\;/", "/\</", "/\>/", "/\?/", "/\//", "/\,/", "/\{/", "/\}/", "/\[/", "/\]/", "/\|/", "/\+/", "/\=/", "/\!/", "/\'/" );
  3. $string = preg_replace($ts,'', $string);
  4. return $string;
  5. }

Report this snippet  

You need to login to post a comment.