SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Strip String of non letters/number

    is there a function that will convert a string to alphanumeric by stripping anything that isn't a number or letter?

    What would also be great is if you could leave spaces in.

    So

    $string = "b'lah blah! bl&ah bl:ah (blah)";

    after going through the function
    it would output

    "blah blah blah blah blah"

  2. #2
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    awesome!! thanks

  4. #4
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    maybe....

    PHP Code:
    $str preg_replace('/[^a-zA-Z0-9]/','',$str); 
    Lemme try to find out what space is..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •