Created
May 16, 2019 08:18
-
-
Save cletsimon/1371941060b91d98cd37d4b3e554c4d6 to your computer and use it in GitHub Desktop.
Create an array containing a range of ips
This file contains hidden or 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 | |
/** | |
* Create an array containing a range of ips | |
* @param string $ip_min minimum ip | |
* @param string $ip_max maximum ip | |
*/ | |
function ipRange($ip_min, $ip_max) { | |
$ip_min_long = ip2long($ip_min); | |
$ip_max_long = ip2long($ip_max); | |
return array_map(function($long){ | |
return long2ip($long); | |
}, range($ip_min_long, $ip_max_long)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment