php-ip
php-ip copied to clipboard
Get all IP's in block according to netmask
Hello i want to calculate and echo all the ips according to IP & netmask for example 127.0.0.1 netmask 255.255.255.192 i want to do for loop on all the block. how it could be !
For example:
$block = new PhpIP\IPv4Block("127.0.0.0/255.255.255.192");
foreach ($block as $ip) {
print "ip: $ip\n";
}
Outputs:
ip: 127.0.0.0
ip: 127.0.0.1
ip: 127.0.0.2
....
ip: 127.0.0.62
ip: 127.0.0.63