i know that one condition that im currently using where it gives an error if $stringabc contains anything but numbers is :
if(preg_match("/[^0-9]/",$stringabc))
I want an if condition where it gives an error if $stringdef contains anything but letters, spaces and dashes (-).
That would be:
if(preg_match('/[^a-z\s-]/i',$stringabc))
for "anything but letters (a-z), spaces (\s, meaning any kind of whitespace), and dashes (-)".
To also allow numbers:
if(preg_match('/[^0-9a-z\s-]/i',$stringabc))
You can use something like:
preg_match("/[^a-z0-9 -]/i", $stringabc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With