How can JSON data with line breaks be written to a file in PHP?

When writing JSON data with line breaks to a file in PHP, you can use the `JSON_PRETTY_PRINT` option in the `json_encode()` function to format the JSON output with line breaks and indentation. This will make the JSON data more readable when written to a file.

$data = ['key1' => 'value1', 'key2' => 'value2'];
$jsonData = json_encode($data, JSON_PRETTY_PRINT);
file_put_contents('output.json', $jsonData);