Weird php problem [SOLVED]

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Weird php problem [SOLVED]

Postby in-sanity » 10. September 2008 18:34

Hi all,

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';
the result being the same, the special characters are simply printed out as they are.

Any help is most appreciated.

Thank you, in-sanity.
in-sanity
 
Posts: 1
Joined: 10. September 2008 18:26

Postby glitzi85 » 10. September 2008 21:45

User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 116 guests