How would I create a preg_replace() that would replace all special characters?

Discussion in 'PHP' started by Imozeb, Apr 21, 2010.

  1. #1
    How would I create a preg_replace() that would replace all special characters? Basicly anything that is not a letter or a number should be deleted.

    Thanks!
     
    Imozeb, Apr 21, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    preg_replace('~[^a-z0-9]+~i', '', $str);
    PHP:
     
    danx10, Apr 21, 2010 IP