Skip to content

Instantly share code, notes, and snippets.

@cletsimon
Created May 16, 2019 08:18
Show Gist options
  • Save cletsimon/1371941060b91d98cd37d4b3e554c4d6 to your computer and use it in GitHub Desktop.
Save cletsimon/1371941060b91d98cd37d4b3e554c4d6 to your computer and use it in GitHub Desktop.
Create an array containing a range of ips
<?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