I'm experiencing some dificulties writing some multi-line text using fwrite().
In short, when running the following code:
- Code: Select all
$file = fopen(EXE_DIR.'\bon.txt', 'w');
foreach ($info as $linie) {
$line .= '1;'.substr(strtoupper($linie['nume_produs']), 0, 20).';1;1;1;'.$linie['pret_produs'].';'.($linie['cantitate_produs']*1000).';0\r\n';
}
$line .= '3';
fwrite($file,$line, strlen($line));
fclose($file);
I get the following result:
- Code: Select all
1;CARTELE DIGI;1;1;1;1;1000;0\r\n1;DISPOZITIV GRI-GRI P;1;1;1;1;1000;0\r\n1;MASă CU Tă;1;1;1;11;11000;0\r\n3
From what I can gather, php does not parse the \r\n special characters for inserting a carriage-return and new-line.
I also tried to use simple
- Code: Select all
echo 'This\r\nis\r\na\r\ntext.\r\n';
Any help is most appreciated.
Thank you, in-sanity.