Re: Working with IP addresses

From: Date: Mon, 18 Mar 2002 23:22:51 +0000
Subject: Re: Working with IP addresses
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-89052@lists.php.net to get a copy of this message
On Mon, 18 Mar 2002, Erik Price wrote: > On Monday, March 18, 2002, at 04:07 PM, Charles Williams wrote: >> So basically I guess I just need a way of, after retrieving the info >> from the DB, splitting the IP (range(s)) apart and then comparing the >> IP entered to those in the array(?) to verify that it was a good entry. > > I would store the IP number into four separate columns in a database > table, one column for each part of the IP. This is just to be safe, > really you only need two (one for the domain and subnet numbers, and the > last for the machine number) but if you ever needed to cross subnets > then you'd be glad you had set up your data in this flexible way. Seems like this isn't such a flexible way to store them (other than as a string, I guess). It's rare that you'd care about particular octets on their own. An IP address is just a 32-bit number, and the easiest way to work with numbers is in their native form. Imagine if you had a bunch of 5-digit numbers you were working with; would you create 5 fields in the database, each to store one digit? miguel

« previous php.general (#89052) next »