function GetCount($filename)
{
$f = fopen($filename,"r");
$count = 0;
while(!feof($f))
{
$buf = fgets($f);
$buf = explode("|",$buf);
if($buf[6] == "2")
$count++;
}
fclose($f);
return $count;
}
function GetRecords($filename,$from,$num)
{
$f = fopen($filename,"r");
$i = $j = 0;
unset($retar);
while(!feof($f) && $i != $num)
{
$buf = fgets($f);
$buf = explode("|",$buf);
if($buf[6] == "2")
{
if($j >= $from)
{
$retar[] = $buf;
$i++;
}
$j++;
}
}
return $retar;
}
$num = 5;
$filename = "file.txt";
$page = ($_GET['page']-1)*$num;
if($ar = GetRecords($filename,$page,$num))
foreach($ar as $value)
{
echo $value[2]."
";
}
$count = ceil(GetCount($filename)/$num);
for($i=1;$i<=$count;$i++)
echo "$i ";
?>