Matching an IP to a CIDR mask in PHP 5?

前端 未结 13 1126
无人共我
无人共我 2020-11-28 04:04

I\'m looking for quick/simple method for matching a given IP4 dotted quad IP to a CIDR notation mask.

I have a bunch of IPs I need to see if they match a range of IP

13条回答
  •  生来不讨喜
    2020-11-28 04:34

    You also can use Net_IPv4 PEAR library.

    function cidr_match($ip, $net){
      include_once("Net/IPv4.php");
      $objIP = new Net_IPv4();
      return $objIP->ipInNetwork($ip, $net);
    }
    

提交回复
热议问题