如何将 IP 地址从头到尾添加到数据库?

How I can add IP Address From start to end to Database?

我想把IP地址从头到尾添加到数据库如

IP Address (Start) 192.168.0.0
IP Address (End) 192.168.0.10

所以它应该像

一样添加到数据库中
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
192.168.0.7
192.168.0.8
192.168.0.9
192.168.0.10

非常感谢我不知道。

$start = '192.168.0.';
$x = 1;
while($x < 11)
{
echo $start.$x."<br>"; // create your code to add to table
    $x++;
}

PHPFiddle:http://phpfiddle.org/main/code/g9a4-qxfy

快速而肮脏,它会注意范围是否跨八位字节

$start = '192.168.0.1';
$end = '192.168.1.255';

$startint = ip2long($start);
$endint = ip2long($end);

while ($startint <= $endint) {
 echo long2ip($startint++); // replace echo with your DB insert
}