How to count lines in the file?

Tell me how to count lines in the file ie the folder and there is an entry in the line, tried $lines = count(file($file)); does not fit
$dir = opendir ("../input/");
 while ( $file = readdir ($dir)){

 if (( $file != ".") && ($file != "..")){
 //how to count lines in the file 
 echo "
$file
 the number of rows in the file

";
}
}
 closedir ($dir);
June 14th 19 at 21:07
2 answers
June 14th 19 at 21:09
This believe of the occurrence of the newline character (\n). Or the same "wc-l" exec-AMB.
June 14th 19 at 21:11
Solved the problem this way
$path = "cron-files";
$dir = opendir($path);
echo "";
while ($file = readdir($dir)) {

 if ( $file != "." && $file != ".." && $file != ".htaccess" ) {
 $content=file_get_contents($path . '/'. $file);

 $files = file($path . '/'. $file); 
 $count = count($files);
 echo "";
}
}
echo "<table border="1"><tbody><tr><th></th><th>file Name</th><th>Lines in the file</th> </tr><tr><td>$content</td><td>$file</td><td>$count</td> </tr></tbody></table>";
closedir($dir);

Find more questions by tags PHP