PHP experts how would you do this?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Azathoth
    Confirmed User
    • Nov 2002
    • 217

    #1

    PHP experts how would you do this?

    In perl say you did this:

    $username =~ tr/[0-9a-zA-Z_\-]//csd;
    ( This would strip all but alphanumeric chars and _ and - chars )

    What would be the equivelant in PHP? I can't seem to find one

    - Az
  • mike503
    Confirmed User
    • May 2002
    • 2243

    #2
    eregi("^[A-Za-z0-9_-]+$",$foo) is what i use.

    so just change that to eregi_replace

    $username = eregi_replace("^[A-Za-z0-9_-]+$","",$username)

    i didn't like relying on \w or \W (and i think i had some problems with it)
    Last edited by mike503; 03-08-2004, 07:49 PM.
    php/mysql guru. hosting, coding, all that jazz.

    Comment

    • Azathoth
      Confirmed User
      • Nov 2002
      • 217

      #3
      Excellent thanks.. I'll give it a shot.

      - Az

      Comment

      Working...