On Tue, Jun 22, 2010 at 9:40 AM, Rick Dwyer <rpdwyer@xxxxxxxxxxxxx> wrote: > Hello List. > > I need to remove characters from a string and replace them with and > underscore. > > So instead of having something like: > > $moditem = str_replace("--","_","$mystring"); > $moditem = str_replace("?","_","$mystring"); > $moditem = str_replace("!","_","$mystring"); > ....etc. > > For every possible character I can think of, is there a way to simply omit > any character that is not an alpha character and not a number value from 0 > to 9? > check the docs, the first parameter may be an array of multiple needles, e.g. $moditem = str_replace(array('-', '?', '!'), '_', $mystring); you could likely do something more elegant w/ preg_replace() tho. -nathan