$myFile = "ip2ban.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); $datatoban = explode(" ",$theData); $i = 1; while $datatoban[$i] { .... here the procedure for ban the ip ... $datatoban[$i] ... $datatoban[$i + 1] i += 2; }