Jump to content

amordeaa

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

amordeaa's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. this has been solved thanks to litebearer
  2. thank you but the problem is how do i read the second field in a csv file and assign it to a variable.
  3. Hello every one i am pretty new to PHP and here is what i am trying to accomplish: file1.csv has DECIMAL IP ADDRESSES range in the format of "202353920","202353951" "410129408","410129663" "410150912","410151167" "410178372","410178375" "410178560","410178815" I know how to read the numbers and place them in a text file by this code: All i am looking for is a code to generate that range between the first 2 fields for example 202353920 202353921 202353922 till 951 and then we move to the next line and do the same. I want the output to be to a file called range.txt. $row = 1; if (($handle = fopen("LONDON1.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) { echo $data[$c]. "<br />\n"; } } this reads the all the fields .. but i dont know how to generate the sequance Part #2 is to get all these numbers and convert them from decimals to x.x.x.x hostnames ( that part i figured out already ) by the this code: function convert1($a){ $b=array(0,0,0,0); $c = 16777216.0; $a += 0.0; for ($i = 0; $i < 4; $i++) { $k = (int) ($a / $c); $a -= $c * $k; $b[$i]= $k; $c /=256.0; }; $d=join('.', $b); return($d); } But part #1 is where i am stuck ( to generate the numbers based on the given range. any help would be really appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.