(PHP 5 >= 5.1.0, PHP 7, PHP 8)
SplFileObject 類為文件提供了一個(gè)面向?qū)ο蠼涌凇?
$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_LINE
刪除行尾的換行符。
SplFileObject::READ_AHEAD
使用 rewind 或 next 方法時(shí),從文件中讀取一行數(shù)據(jù)。
SplFileObject::SKIP_EMPTY
跳過文件中的空白行。這需要啟用
READ_AHEAD
標(biāo)志,以達(dá)到預(yù)期的效果。
SplFileObject::READ_CSV
以 CSV 行的形式讀取。