- 함수 cidr2range()
- 함수 cidrToRange()
1 Bash[ | ]

Bash
Copy
ipcalc 192.168.0.0/16 | grep ^HostM | awk '{print $2}'
# 192.168.0.1
# 192.168.255.254
2 PHP[ | ]

PHP
Copy
function cidr2range($cidr) {
list($ip,$bits) = explode('/', $cidr);
return ['min' => long2ip( ip2long($ip) & (-1<<(32-$bits)) ),
'max' => long2ip( ip2long($ip) + pow(2,32-$bits) - 1 )];
}
print_r( cidr2range('192.168.0.0/16') );
# Array
# (
# [min] => 192.168.0.0
# [max] => 192.168.255.255
# )
3 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.
PHP 파일 다운로드 구현 2 (한글 파일명 지원) ― …PHP에서 오라클 DB 사용 ― YoWuPHP 파일 업로드 구현 ― 일리단사오육칠PHP 파일 업로드 구현 ― JmnotePHP 파일 다운로드 구현 2 (한글 파일명 지원) ― AnmkstLib my.php ― 신정섭Lib my.php ― Jmnote로또번호 생성 ―Pinkcrimson