You have it the wrong way around. The pattern comes before. Try this:
$return = preg_match("/^[a-zA-Z ]+$/", $string);
Also, the docs can be read here.
Domanda
For some reason I keep getting this error in my PHP for preg_match(): Delimiter must not be alphanumeric or backslash
even though I have a delimiter in my preg_match regexp, so what is going on? This is happening for each and ever preg_match function i call in my code. I don't know what is wrong with it.
$return = preg_match($string, "/^[a-zA-Z ]+$/")
Soluzione
You have it the wrong way around. The pattern comes before. Try this:
$return = preg_match("/^[a-zA-Z ]+$/", $string);
Also, the docs can be read here.