im trying to get any input-ed data to be replaced by the value '7', if it is not a number between 0 and 9.
Here's my code atm:
echo "Enter no. of days to search: ";
$handle = fopen ("php://stdin","r");
$days = fgets($handle);
$days2 = str_replace("\n", '', $days);
if ($days2 == '/^[0-9]{1}$/'){
$days2 = "7";}
it doesnt replace any input (letters or numbers) with 7 though! Help please! Thanks
Edit:
if ($days2 >= 0 && $days2 <= 9){
}
else $days2 = "7";
works but only for numbers outside the range, not for if i input letters
if ($days2 < 0 || $days2 > 9){maybe?