Last active
May 24, 2017 06:21
-
-
Save edmhs/8bdc99b5f69072cb5ade4b36e8630429 to your computer and use it in GitHub Desktop.
Return array with all ip addreses from ip addresses subnet - PHP Subnet mask calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$range = "194.8.42.0/24"; | |
function ipListFromRange($range){ | |
$parts = explode('/',$range); | |
$exponent = 32-$parts[1].'-'; | |
$count = pow(2,$exponent); | |
$start = ip2long($parts[0]); | |
$end = $start+$count; | |
return array_map('long2ip', range($start, $end) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment