(PHP 5 >= 5.1.0, PHP 7, PHP 8)
SplFileObject::setMaxLineLen — Set maximum line length
Sets the maximum length of a line to be read.
maxLength
The maximum length of a line.
Nenhum valor é retornado.
Throws DomainException when
maxLength
is less than zero.
Exemplo #1 SplFileObject::setMaxLineLen() example
<?php
$file = new SplFileObject("lipsum.txt");
$file->setMaxLineLen(20);
foreach ($file as $line) {
echo $line . "\n";
}
?>
Contents of lipsum.txt
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis nec sapien felis, ac sodales nisl. Nulla vitae magna vitae purus aliquet consequat.
O exemplo acima produzirá algo semelhante a:
Lorem ipsum dolor s it amet, consectetu r adipiscing elit. Duis nec sapien fel is, ac sodales nisl . Nulla vitae magna v itae purus aliquet consequat.