On Mon, 18 Mar 2002, Charles Williams wrote:
> There will be a form with a text box to allow IP address entries as follows:
> or
> or
> or
> The above a just a few examples.  I need to be able to grab either the IP
> addresses or the ranges and verify that when an IP is entered at a later
> date and compared to the above types of previously saved data that the IP is
> within the range(s).
> I hope I explained that ok. ;)
> 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.

It's not exactly clear to me what your question is.

But, as to the general question of representing and comparing IP addresses 
internally, I guess first you'd want to pick a representation that 
efficiently and flexibly captures the values you expect to work with.

Ordinarily I would suggest CIDR subnets but the sample IP addresses you 
provided do not comply - they seem to be random numbers. Is this because 
you need to deal with arbitrary sets of IP addresses rather than valid 
subnets, or because you were just in a hurry while typing your message to 
the list?

Also, I wouldn't recommend using the slash to identify ranges of IP 
addresses, because the slash already has a specific meaning in this 
context: the number after it specifies the size of the subnet mask. For 
instance, to refer to the range, you'd write

Anyway, I have a few ideas in mind but with an answer to the above 
question I'd be able to give you what may be an optimal representation and 


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to