tags:

views:

77

answers:

1

Hello,

I would like to filter a string and strip all characters that are not alphanumeric or a hyphen. Is there some tunction in PHP for that?

Not sure how to do it.

+3  A: 

you could use a regular expression to search for such strings and then replace them with the empty string. The expression could look like: [^a-zA-Z0-9\-]

See preg_replace

FrustratedWithFormsDesigner