How would I do this?:
I want to search a string contained in a variable for illegal characters, such as ! " £ $ %, etc... If one is present, then display an error message.
I've taken a look at preg_match, but I'm not sure how to use it.
I think you could get away with [man]strpos[/man] but... using eregi... I would think something like...
if (eregi('[!"£\$%]', $string) //do this
would work.. (I think, I dont do reg ex much)
The corresponding expression for preg_replace would be /[!"£$%]/ - but either way is overkill. You can use [man]strcspn[/man], and if the returned length is less than the length of the original string, then there was an illegal character.