Anyone know how to strip all non-english alpha from string?

Discussion in 'PHP' started by marketjunction, Dec 20, 2005.

  1. #1
    Hi all,

    I have a string ($str). I am trying to remove everything that is not an ENGLISH letter from a to z or number from 0 -9.

    My string has some foreign chars in it like †and ? and ! and % and who knows what else.

    Any ideas?

    Thanks
     
    marketjunction, Dec 20, 2005 IP
  2. tandac

    tandac Active Member

    Messages:
    337
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    $str=preg_replace("/[^a-zA-Z0-9]+/","",$str);
    PHP:
     
    tandac, Dec 20, 2005 IP
  3. marketjunction

    marketjunction Well-Known Member

    Messages:
    3,779
    Likes Received:
    187
    Best Answers:
    0
    Trophy Points:
    183
    #3
    thanks. Not sure how I got on the wrong track. I was trying some other stuff with not much luck.
     
    marketjunction, Dec 21, 2005 IP