Matching IPv6 address to a CIDR subnet
问题 Is there a good way to match an IPv6 address to an IPv6 subnet using CIDR notation? What I am looking for is the IPv6 equivalent to this: Matching an IP to a CIDR mask in PHP 5? The example given above can't be used since an IPv6 address is 128 bits long, preventing the bitwise left-shift from working properly. Can you think of any other way? EDIT: Added my own solution to the list of answers. 回答1: Since you cannot convert IPv6 addresses to integer, you should operate bits, like this: $ip=