<?php
$filesperpage=2;
$i=0;
$page=isset($_GET['p'])?$_GET['p']:1;
$theFile = file_get_contents ('test.txt');
$lines = array ();
$lines = explode ("\n", $theFile);
$lineCount = count ($lines);
if ($i>=($page-1)*$filesperpage and $i<$page*$filesperpage) {
for ($k = 0; $k < $lineCount; $k++){
echo $lines[$k]."<br>";
}
}
$i++;
$pages=ceil($i/$filesperpage);
for ($p=1;$p<=$pages;$p++){
echo "<a href=\"?p=$p\">$p</a>\n";
}
?>