3

Pls help,

I have a form which contains two fields to enter ip range say

      |iprange1| and  |iprange2|

What I want to print all ip between iprange1 and iprange2. Lets say I want to print ip's between

    192.168.1.2 and 192.168.1.10

how to do this?

4

1 回答 1

3

demo : http://codepad.org/3QDQ2OVK.

$ip1 = '192.168.1.2';
$ip2 = '192.168.1.10';

for ($ip = ip2long($ip1); $ip<=ip2long($ip2); $ip++)
{
    echo long2ip($ip) . "\n";
}

Thanks to NullUserException.

于 2012-10-16T05:52:29.883 回答