Hi,
How do I test to see if a number is within a certain range in PHP?
So …
if($number, $low, $high) TRUE : FALSE;
Hi,
How do I test to see if a number is within a certain range in PHP?
So …
if($number, $low, $high) TRUE : FALSE;
[font="arial, verdana, tahoma, sans-serif"][size="2"][font="Arial,"][font="arial, verdana, tahoma, sans-serif"][size="3"][size="2"][size="3"]
return (($number >= $low) && ($number <= $high));
[/size][/size][/size][/font][/font][/size][/font]
Cheers. I have done it that way now, I was just wondering if there was a pre-defined function. Anyways thanks
In Yii, you could also use a validation rule in the model,
For example, this is for an attribute named ‘attribute_name’, with min of 0 and max of 9
public function rules()
{
return array(
array('attribute_name', 'numerical', 'min'=>0, 'max'=>9)
);
}