Re: IPs comparing

From: Date: Wed, 27 Nov 2002 18:29:18 +0000
Subject: Re: IPs comparing
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-126324@lists.php.net to get a copy of this message
On Thu, 28 Nov 2002 02:19:18 +0800 Jason Wong <php-general@gremlins.biz> wrote: > > I have several subnets in my network and want to show different webs > > depending on the subnet the user was. > > I know how to get the IP but not how to compare two IPs numeracally, > > I mean: > > If ((USER-IP > 192.168.0.1) && (USER-IP < 192.168.0.255)) > > Else if ((USER-IP > 192.168.1.1) && (USER-IP < 192.168.1.255)) > > What do you suggest me? > > If the cases are as simple as the examples above then you can just use > string comparison functions Or look at the ip2long/long2ip functions (and there's a couple of other IP handling classes in PEAR) Alister

« previous php.general (#126324) next »