Re: PHP and Ranges

From: Date: Fri, 20 Apr 2001 00:26:11 +0000
Subject: Re: PHP and Ranges
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49463@lists.php.net to get a copy of this message
One way is: $min = 0; $max = 65535; if ($var >= $min && $var <= $max) { ... } Though I haven't heard of a range comparison, it would be nice if one existed...especially if it could be something like "0-4, 6-8, 9-21", and it would return true of the value was within any of the specified ranges. But I don't know of it's specific existance. -- Plutarck Should be working on something... ...but forgot what it was. ""Jason Caldwell"" <jason@thinkingman.org> wrote in message news:9bnos3$flm$1@toye.p.sourceforge.net... > is there a way to compare a value to a preset range. > > for example; > > $preset_ range = [0...65535] > > $a[0] = "12"; > $a[1] = "198"; > $a[2] = "B"; > > $ac = count($a); > > for($x=0; $x < $ac; $x++) > { > if($a[$x] != $preset_range) > { > $valid = 0; > } > else > { > valid = 1; > } > > print($valid . "\n"); > } > > output should look like: > 1 > 1 > 0 > > how is this accomplished in PHP? > > thanks. > jason > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#49463) next »