There is a file and data in it. I need to break it into pieces, for example, 10 pieces each and display it in the list. I wrote a small function that seems to work, but it does not display the last 10 how to fix it, I got confused at all.
$p = 1; if(!empty($_GET['p'])) $p = intval($_GET['p']); // Полный путь к файлу $file0 = file($_SERVER['DOCUMENT_ROOT']."/arrays/file.log"); /* file.log Number 1 Number 2 Number 3 ... Number 999 Number 1000 */ // Количество показываемых данных на странице $lstvars= 10; // Считает сколько массивов в переменной $score = count($file0); $pages = $score/10; if($score > $lstvars){ $sarray = "0"; if($p > 1){ $end = $p.$sarray; if($end > $lstvars){ $start = $end - $lstvars; $sarray = $start; } } for ($i=0; $i < $lstvars; $i++) { echo $file0[$sarray]; $sarray =$sarray +1; } }else{ foreach ($file0 as $key => $value) { echo $value; } } echo "<br>"; for ($i=1; $i < $pages; $i++) { echo "<a href='?p=".$i."'>Page ".$i."</a> | "; }