Skip to content

Instantly share code, notes, and snippets.

@Foxy79
Created February 24, 2016 11:23
Show Gist options
  • Save Foxy79/ec266853807fb97fc197 to your computer and use it in GitHub Desktop.
Save Foxy79/ec266853807fb97fc197 to your computer and use it in GitHub Desktop.
<?php
function cidr2mask($mask){
return long2ip(pow(2,32) - pow(2, (32-$mask)));
}
function mask2cidr($mask){
$a=strpos(decbin(ip2long($mask)),"0");
if (!$a){$a=32;}
return $a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment