PDA

View Full Version : Removing characters from a string


Vman
01-25-2005, 05:30 AM
I have a text field that, when submitted, I'd like to strip any special characters out of such as apostrophes and ampersands and so forth. Should I use ereg_replace for this or something else? The reason I need to do this is because I'm using the value of the field in a path. Any advise? Thanks.

petefs
01-25-2005, 03:46 PM
Unless you need the regexp support you should just use str_replace. If that doesn't help, give us an example or two of what you might see and what you want as a result ^_^

Vman
01-25-2005, 06:28 PM
I believe that's what I was looking for. Thanks!

freddycodes
01-25-2005, 07:41 PM
And always use preg_* functions instead of ereg_* functions, they are proven faster and more efficient. I can provide documentation if anyone is looking for it.