This is what i've got so far, but i cant seem to figure out the proper way to have it remove spaces. Any ideas?
preg_replace('[a-z]', "", strtolower($_GET["myvar"]));
This is what i've got so far, but i cant seem to figure out the proper way to have it remove spaces. Any ideas?
preg_replace('[a-z]', "", strtolower($_GET["myvar"]));
I'm guessing you are trying to remove everything except lowercase letters. If that is the case, try this:
This is will transform
$_GET["myvar"]
to all lowercase letters then remove anything that isn't a lowercase letter.technically, there couldn't ever be any upper case letters, since you're guaranteeing that all letters will be lower case before the regex ever gets its hands on the string. In any case, this regex will remove anything that ISN'T a-z.
You almost had it, and were just missing the inversion (
^
) and the delimiters (//
).