Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. /**
  2. * Get the IP range block based on CIDR
  3. *
  4. * @param string $cidr 127.0.0.1/28
  5. * @return array
  6. */
  7. function ipCalculateRange($cidr) {
  8. $range = array();
  9. $cidr = explode('/', $cidr);
  10. $range[0] = long2ip((ip2long($cidr[0])) & ((-1 << (32 - (int)$cidr[1]))));
  11. $range[1] = long2ip((ip2long($range[0])) + pow(2, (32 - (int)$cidr[1])) - 1);
  12. return $range;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement