I try to validate fields. Three fields that may only contain numbers. The fields have the variable names $num1, $num2, $num3. I have put them in an array and then I run preg_match but it does not work. How should I do?
$valnum = array (‘$num1’, ‘$num2’, ‘$num3’);
if (preg_match('/[0-9]/', $valnum)){
echo $mycost;
}
else {
echo 'You can only enter numbers';
}
would be a better approach
//worked up example:
?>
returns 99.99