SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    boiler up blackdog's Avatar
    Join Date
    Jul 2002
    Location
    Purdue
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing all characters that are not #'s or letters

    Is there a function that will remove all characters that aren't letters and numbers? I'm doing a mod_rewrite to include the title of the page in the URL and i don't want punctuation, etc to show up in the url

    thanks!

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $r preg_replace('/[^a-z0-9]+/i'''$s); 
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    boiler up blackdog's Avatar
    Join Date
    Jul 2002
    Location
    Purdue
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks! but how can i modify that to keep spaces or dashes?

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $r preg_replace('/[^a-z0-9 \-]+/i'''$s); 
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    boiler up blackdog's Avatar
    Join Date
    Jul 2002
    Location
    Purdue
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks!


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
  •