IPUtils is a PHP library for the parsing and formatting of IPv4/IPv6 addresses and CIDR ranges. It includes the IPSet class.

edit