1--TEST--
2fputcsv() with user provided eol
3--FILE--
4<?php
5$data = [
6    ['aaa', 'bbb', 'ccc', 'dddd'],
7    ['123', '456', '789'],
8    ['"aaa"', '"bbb"'],
9];
10
11$eol_chars = ['||', '|', '\n', "\n", "\0"];
12foreach ($eol_chars as $eol_char) {
13    $stream = fopen('php://memory', 'w+');
14    foreach ($data as $record) {
15        fputcsv($stream, $record, ',', '"', '\\', $eol_char);
16    }
17    rewind($stream);
18    echo stream_get_contents($stream), "\n";
19    fclose($stream);
20}
21?>
22
23--EXPECTF--
24aaa,bbb,ccc,dddd||123,456,789||"""aaa""","""bbb"""||
25aaa,bbb,ccc,dddd|123,456,789|"""aaa""","""bbb"""|
26aaa,bbb,ccc,dddd\n123,456,789\n"""aaa""","""bbb"""\n
27aaa,bbb,ccc,dddd
28123,456,789
29"""aaa""","""bbb"""
30
31aaa,bbb,ccc,dddd%0123,456,789%0"""aaa""","""bbb"""