note 95816 deleted from function.ip2long by cmb
| From: | cmb@php.net | Date: | Sun, 29 Sep 2019 07:37:47 +0000 |
| Subject: | note 95816 deleted from function.ip2long by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212406@lists.php.net to get a copy of this message | ||
Note Submitter: Mam(O)n
----
Another CIDR function, but with sanity check:
<?php
function mask2prefix($mask)
{
if (($long = ip2long($mask)) === false)
return false;
for ($prefix = 0; $long & 0x80000000; ++$prefix, $long <<= 1) {}
if ($long != 0)
return false;
return $prefix;
}
?>