Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Get the IP range block based on CIDR
- *
- * @param string $cidr 127.0.0.1/28
- * @return array
- */
- function ipCalculateRange($cidr) {
- $range = array();
- $cidr = explode('/', $cidr);
- $range[0] = long2ip((ip2long($cidr[0])) & ((-1 << (32 - (int)$cidr[1]))));
- $range[1] = long2ip((ip2long($range[0])) + pow(2, (32 - (int)$cidr[1])) - 1);
- return $range;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement