|
Posted by Els on 12/21/06 09:41
Michael Fesser wrote:
> .oO(KoopaJah)
>
>>A simple possibility could be to declare an array with all the values
>>that $a cannot take and use the in_array() function. Something like this:
>>
>>$forbiddenValues = array(1,2,3,4,17,30);
>>if (in_array($a, $forbiddenValues ))
>>{
>> // some code
>>}
>>
>>But it does not allow you to define something like "all values between 1
>>and 4".
>
> if (in_array($a, range(1, 4))) {
> ...
> }
Could I mix those two things, like so:
$values = array(range(1, 4),17,30);
if (in_array($a, $values))
{
echo "bingo";
}
?
--
Els http://locusmeus.com/
Navigation:
[Reply to this message]
|