In Ipv4 we can use ip2long
to convert it to number,
How to convert ipv6 compressed to number in PHP?
I tried inet_pton and it\'s not working.
<OK, some revelations from chat with Ben Wong... The REAL issue is optimizing lookups in a DB about a geoIP service.
The DB layout offered by this geoIP database is too slow to just have plain ol' BETWEEN applied on the start and end, even though the storage is the most economic one you can get.
The proposal I first outlined in the chat was to fragment the IP address into 4 ints which are compared sequentially, but on second though, that may not be enough, since you're still searching over the entire DB, which is over 1 million rows. I also had an idea about doing matches with subnet masks, but given that some ranges are not within large masks, doing this may, again, not be enough.
I'll see what I can do, and I'll edit this answer. But I'm posting this in the meantime for anyone else willing to assist in this.