Monday, January 20, 2014

PHP Function To Convert Netmask To CIDR

<?php
function mask2cidr($mask){
     $long = ip2long($mask);
     $base = ip2long('255.255.255.255');
     return 32-log(($long ^ $base)+1,2);     
}
?>

No comments:

Post a Comment