title: Matching IPv6 address to a CIDR subnet
body: <p>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:
  <a href="https://stackoverflow.com/questions/594112/matching-an-ip-to-a-cidr-mask-in-php5">Matching an IP to a CIDR mask in PHP 5?</a></p>
  
  <p>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?</p>
  
  <p>EDIT: Added my own solution to the list of answers.</p>