note 123839 added to function.ip2long
| From: | Anonymous@php.net | Date: | Fri, 10 May 2019 11:04:30 +0000 |
| Subject: | note 123839 added to function.ip2long | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-211002@lists.php.net to get a copy of this message | ||
/**
* convert cidr to ip range
* From: <https://github.com/www-schat-top>
* @param string $cidr "192.168.0.0/23"
* @return array ["192.168.0.0", "192.168.1.255"]
*/
function cidr2range($cidr){
list( $subnet, $mask ) = explode( '/', $cidr );
return [long2ip($subnet), long2ip(ip2long( $subnet ) | (pow(2,( 32 - $mask ))-1))];
}
----
Server IP: 208.43.231.9
Probable Submitter: 82.199.130.26 (proxied: 134.159.87.177)
----
Manual Page -- http://php.net/manual/en/function.ip2long.php
Edit -- https://master.php.net/note/edit/123839
Del: integrated -- https://master.php.net/note/delete/123839/integrated
Del: useless -- https://master.php.net/note/delete/123839/useless
Del: bad code -- https://master.php.net/note/delete/123839/bad+code
Del: spam -- https://master.php.net/note/delete/123839/spam
Del: non-english -- https://master.php.net/note/delete/123839/non-english
Del: in docs -- https://master.php.net/note/delete/123839/in+docs
Del: other reasons-- https://master.php.net/note/delete/123839
Reject -- https://master.php.net/note/reject/123839
Search -- https://master.php.net/manage/user-notes.php