Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a php script that wirtes into a file sequentally.
it writes like this:
ABCD...
i want to write like this.
A
B
C
D
...
how i change my Code.
thanks your answer

PHP
<?php
header ('Location:');
$handle = fopen("MyFile.txt", "a");
foreach($_GET as $variable => $value) {
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "rn");
}
fwrite($handle, "rn");
fclose($handle);
exit;
?>
Posted
Updated 6-Apr-21 15:23pm

I am not a PHP guy. My guess it you are writing fwrite($handle, "rn"); for line break. It should be "\r\n" or "\\r\\n" depending what PHP supports. You can also try PHP_EOL. Good luck.
 
Share this answer
 
Comments
mahmoodof 28-Mar-14 2:58am    
thank you too much
You need to add the end-of-line characters after each line. The only problem is that these characters are system-dependent: http://en.wikipedia.org/wiki/End-of-line[^].

PHP has the predefined constant PHP_OEL, available since PHP 4.3.10 and PHP 5.0.2: http://www.php.net/manual/en/reserved.constants.php[^].

Depending on the OS, it will take the value of '\r\n', 'r' or '\n'; the constant will guarantee you use correct value for each OS.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900