Reputation: 552
I would like a way to break the line when it gets to 360 characters in a txt file.
Example:
In my script my output
My code to write in file
$string = $data.'*'."\n";
$fp = fopen( 'registro.txt', 'a+' );
if( !$fp ){
echo 'Erro inesperado, não foi possivel abrir o arquivo';
exit;
}else{
fwrite( $fp, $stringSEFIP."\n");
}
Upvotes: 0
Views: 64
Reputation: 5203
Try something like this:
$string = $data.'*'."\n";
$skip = 360;
$fp = fopen( 'registro.txt', 'a+' );
if( !$fp ){
echo 'Erro inesperado, não foi possivel abrir o arquivo';
exit;
}else{
$pos = 0;
while ($pos < strlen($str)) {
fwrite( $fp, substr($stringSEFIP, $pos, $skip) . PHP_EOL);
$pos += $skip;
}
}
Upvotes: 1