Fwrite new line

A simple one!

To write a new line using fwrite in PHP, you can use the following syntax:

fwrite($fp, "\n");

Where $fp is the file pointer (a resource returned by fopen).

Alternatively, you can use the PHP constant PHP_EOL which represents the end-of-line character for the current platform:

fwrite($fp, PHP_EOL);

This will write a new line character that is specific to the platform you're running on (e.g. \n on Unix, \r\n on Windows, etc.).

For example:

$fp = fopen('example.txt', 'w');
fwrite($fp, "Hello, world!\n");
fwrite($fp, PHP_EOL);
fwrite($fp, "This is a new line.");
fclose($fp);

This will write the following to the file example.txt:

Hello, world!
This is a new line.