Add all IP Address to MySQL Database – PHP Script

Internet Protocol is known as IP and one day all device will be controlled  with IP address. I tried to add all IPV4 IP address into MySQL database with php script and yes, I  did it. But, it takes a lot of space! I added IP address to MySQL database from 1.0.0.0 to 1.1.255.255 and it takes 300MB + space! Anyway if you need to print all IP address or y0u wish to add them into MySQL database, follow the following  simple php script.

Well, First, We will see how to print ip address

<?php 
echo "IP address <br>";

for ($l = 1; $l <= 255; $l++) {
  for ($k = 0; $k <= 255; $k++) {
	  for ($j = 0; $j <= 255; $j++) {
   		 for ($i = 0; $i <= 255; $i++) {
                  echo "$l.$k.$j.$i <br>";
                  $count+=1;
                 }
         }
   }
}
echo "Total IP $count";
?>

We use 4 loop to print ip address. Continue reading Add all IP Address to MySQL Database – PHP Script