A serie of network util functions
$ git clone https://github.com/girorme/net-utils
$ cd net-utils
$ composer install
The range functions actually generates the ips using generator to avoid extensive memory usage and memory limit, so the result of
Ip::range
,Ip::cidr
for example need to be iterated
require_once __DIR__ . '/vendor/autoload.php';
try {
$range = NetUtils\Ip::range('192.168.0.1', '192.168.0.255');
foreach ($range as $ip) {
echo $ip . PHP_EOL;
}
} catch (\Exception $e) {
// catch
}
require_once __DIR__ . '/vendor/autoload.php';
try {
$range = NetUtils\Ip::cidr('192.168.0.1/24');
foreach ($range as $ip) {
echo $ip . PHP_EOL;
}
} catch (\Exception $e) {
// catch
}
For examples check the examples
folder