<?php $int = 12; $min = 1; $max = 100; if(filter_var($int,'FILTER_VALIDATE_INT', array("options"=>array("min_range"=>$min,"max_range"=>$max))) === false){ echo ("The number is valid"); }else{ echo ("The number is not valid"); } ?>
电动小老虎2017-11-21 00:48:21
先 $arr = range(1,100);
foreach($arr as $k $v)
{
if($int === $v)
{
echo '在范围内';
}else{
echo '不在';
}
这样行吗?