Oihana PHP

countFileLines.php

Table of Contents

Functions

countFileLines()  : int
Counts the number of lines in a file.

Functions

countFileLines()

Counts the number of lines in a file.

countFileLines(string|null $file) : int

This function efficiently counts lines by reading the file in chunks, making it suitable even for very large files.

Example usage:

use function oihana\files\countFileLines;

$count = countFileLines('/path/to/file.log');
Parameters
$file : string|null

The full path to the file.

Tags
throws
FileException

If the file does not exist, is not readable, or cannot be opened.

author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
int

The total number of lines in the file.


        
On this page

Search results