preg replace? str_replace ? function?
Posted: Tue Mar 08, 2005 4:33 am
I am currently developing a site and am pretty new to php. I have a form where a user can add a keyword (unique) to be used in the menu system
However, i would like the user to only be able to enter in this field, the letters A-Z, a-z and 0-9, with no other chars allowed.Any other chars should be just stripped out.
I currently do this... but its a poor way to do it...
this list can get really long... any idea on a better way would be grateful.. thanks :>
an example string "hello!"$%%^^*" would just be "hello"
However, i would like the user to only be able to enter in this field, the letters A-Z, a-z and 0-9, with no other chars allowed.Any other chars should be just stripped out.
I currently do this... but its a poor way to do it...
Code: Select all
$keyword = str_replace ( '?', '', $keyword );
$keyword = str_replace ( '&', '', $keyword );
$keyword = str_replace ( '!', '', $keyword );an example string "hello!"$%%^^*" would just be "hello"