<?php
$pattern = "/^[A-Za-z0-9_\- ]+$/";
if(preg_match( $pattern, "$variable" ) ) {
echo "match\n";
} else {
echo "no match\n";
}
?>
In the above example I am checking that my variable (ie "$variable") only contains alpha/numeric charcaters plus hyphans and underscores.
What if I have many variables? Is there a way to adapt this code into an array rather than having to repeat this code for how ever many variables I have?
cheers :eek: