Use ip2long()and long2ip():
function ip_range($from, $to) {
$start = ip2long($from);
$end = ip2long($to);
$range = range($start, $end);
return array_map('long2ip', $range);
}
The above turns two IP addresses into numbers (using the basic functions of PHP), creates a range of numbers, and then turns this range of numbers into IP addresses.
If you want them to be separated by spaces, just the implode()result.
source
share