Skip to content

Instantly share code, notes, and snippets.

@proclnas
Created May 20, 2016 06:28
Show Gist options
  • Save proclnas/56ffc9e1e41e504a93f6cddc8b6f6253 to your computer and use it in GitHub Desktop.
Save proclnas/56ffc9e1e41e504a93f6cddc8b6f6253 to your computer and use it in GitHub Desktop.
<?php
function ipRange($startIp, $endIp) {
$startIp = ip2long($startIp);
$endIp = ip2long($endIp);
$ips = range($startIp, $endIp);
return array_map('long2ip', $ips);
}
echo '<pre>';
var_dump(ipRange('192.168.0.1', '192.168.0.10'));
@proclnas
Copy link
Author

Improved method using generator in the php-utils::Network:
Network

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment