How do I output the line number of the file page by page?

0 like 0 dislike
6 views
Greetings to all prompt how to implement, there are say 100 txt. file contains rows with different number , how do I output the line number of the file page by page 5ae6044499614266592088.png.
I already did so the point that appears in all files leash one sum on the last file

$files = glob("../data/*.*"); $fnumber = '10'; foreach($files as $file){ $name[] = basename($file); $size = round(filesize($file)/1024,2); $count = count(file($file)); $summa += count(file($file)); } $counts = count($files); $pages = ceil($counts/$fnumber); $page = $_GET['page']; if(!$page OR $page==") { $nav_min = 0; $nav_max = $fnumber - 1; }else{ $nav_min = ($page * $fnumber) - $fnumber; $nav_max = ($fnumber * $page) - 1; } # Output for($i = $nav_min; $i <= $nav_max; $i++) { echo $name[$i]; // displays echo $size; // NOT displayed echo $count; // NOT displayed } echo $summa; // displays # Navigation for($fpr = " $i =1; $i <= $pages; $i++) { echo $fpr=(($i == 1 || $i == $pages || abs($i-$page) < 2) ? ($i == $page ? "[$i] | " : ''.$i.'  | ') : (($fpr == ' ... ' || $fpr == ")? ": '... ')); }
by | 6 views

1 Answer

0 like 0 dislike
If it happens on Linux and all the files in one folder, you can do this:
$path = 'dirname/*'; // all files in dirname $result = shell_exec('wc-l' . $path);

in $result you will get a string of the form
10 filename1.txt 17 filename2.txt 27 total

Only have to parse this string in a convenient way.

Another way: count(file($filename))
First you need to get all the paths to the files.
Often it is convenient to do with php.net/manual/ru/function.glob.php

Iterate through the array of paths and run on each count(file($filename)) storing the result into an array, simultaneously summing up in a separate variable.
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
33,967 users