(PHP 5 >= 5.1.0, PHP 7, PHP 8)
The SplFileObject class offers an object-oriented interface for a file.
$filename,$mode = "r",$useIncludePath = false,$context = null$separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false$fields,$separator = ",",$enclosure = "\"",$escape = "\\",$eol = "\n"$separator = ",", string $enclosure = "\"", string $escape = "\\"): void$mode = "r", bool $useIncludePath = false, ?resource $context = null): SplFileObjectSplFileObject::DROP_NEW_LINEDrop newlines at the end of a line.
SplFileObject::READ_AHEADRead on rewind/next.
SplFileObject::SKIP_EMPTYSkips empty lines in the file. This requires the READ_AHEAD flag be enabled, to work as expected.
SplFileObject::READ_CSVRead lines as CSV rows.