I wanted to get the IPv4 range of a WHOIS record provided by
because unlike other RIRs
they don't supply you with the range, but with just
a CIDR notation.
To make matters worse, they give 'incomplete' net numbers. The only working "CIDR to IP range" function I could find didn't accept it, so I had to sprinkle some magic.
cidr_conv() is written by someone unknown in 2003 and can be
found in the PHP.net comments of the Network functions page.
So you can enter
$incomplete_cidr_notation and get
But even if you enter
17/8 (or with a leading zero, straight out of IANAs IP allocation file) it will work and you'll get, in this case, Apple's IP range
Update: Since this article is getting quite a few hits and when I read this back it seemed kinda confusing, I've recreated this a bit better as a Gist.